more small changes, comments, and docstrings :)
This commit is contained in:
parent
a82c7ba5ba
commit
74cd20c55d
1 changed files with 8 additions and 3 deletions
11
core/bot.py
11
core/bot.py
|
@ -5,8 +5,10 @@ import re
|
||||||
import config
|
import config
|
||||||
import irc
|
import irc
|
||||||
|
|
||||||
# strip all spaces and capitalization from the connection name
|
|
||||||
def clean_name(n): return re.sub('[^A-Za-z0-9_]+', '', n.replace(" ", "_"))
|
def clean_name(n):
|
||||||
|
"""strip all spaces and capitalization"""
|
||||||
|
return re.sub('[^A-Za-z0-9_]+', '', n.replace(" ", "_"))
|
||||||
|
|
||||||
|
|
||||||
class Bot(object):
|
class Bot(object):
|
||||||
|
@ -23,7 +25,7 @@ class Bot(object):
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
|
"""connect to all the networks defined in the bot config"""
|
||||||
for name, conf in self.config['connections'].iteritems():
|
for name, conf in self.config['connections'].iteritems():
|
||||||
# strip all spaces and capitalization from the connection name
|
# strip all spaces and capitalization from the connection name
|
||||||
name = clean_name(name)
|
name = clean_name(name)
|
||||||
|
@ -39,6 +41,7 @@ class Bot(object):
|
||||||
self.logger.debug("({}) Created connection.".format(name))
|
self.logger.debug("({}) Created connection.".format(name))
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
"""create the logger and config objects"""
|
||||||
# logging
|
# logging
|
||||||
self.logger = self.get_logger()
|
self.logger = self.get_logger()
|
||||||
self.logger.debug("Logging engine started.")
|
self.logger.debug("Logging engine started.")
|
||||||
|
@ -49,9 +52,11 @@ class Bot(object):
|
||||||
self.logger.debug("Config loaded.")
|
self.logger.debug("Config loaded.")
|
||||||
|
|
||||||
def get_config(self):
|
def get_config(self):
|
||||||
|
"""create and return the config object"""
|
||||||
return config.Config(self.name)
|
return config.Config(self.name)
|
||||||
|
|
||||||
def get_logger(self):
|
def get_logger(self):
|
||||||
|
"""create and return the logger object"""
|
||||||
# create logger
|
# create logger
|
||||||
logger = logging.getLogger(self.name)
|
logger = logging.getLogger(self.name)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
Reference in a new issue