stuff
This commit is contained in:
parent
c2271b1195
commit
d4968d478e
3 changed files with 13 additions and 17 deletions
21
cloudbot.py
21
cloudbot.py
|
@ -8,7 +8,6 @@ import signal
|
||||||
# check python version
|
# check python version
|
||||||
if sys.version_info < (2, 7, 0):
|
if sys.version_info < (2, 7, 0):
|
||||||
print "CloudBot requires Python 2.7 or newer."
|
print "CloudBot requires Python 2.7 or newer."
|
||||||
sys.stderr.write(os.linesep)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# set up enviroment
|
# set up enviroment
|
||||||
|
@ -27,15 +26,13 @@ def exit_gracefully(signum, frame):
|
||||||
original_sigint = signal.getsignal(signal.SIGINT)
|
original_sigint = signal.getsignal(signal.SIGINT)
|
||||||
signal.signal(signal.SIGINT, exit_gracefully)
|
signal.signal(signal.SIGINT, exit_gracefully)
|
||||||
|
|
||||||
# little restart loop
|
# create new bot object
|
||||||
while True:
|
cloudbot = bot.Bot()
|
||||||
# create new bot object
|
|
||||||
cloudbot = bot.Bot()
|
|
||||||
|
|
||||||
cloudbot.run()
|
cloudbot.run()
|
||||||
if cloudbot.do_restart:
|
if cloudbot.do_restart:
|
||||||
# this kills the bot
|
# this kills the bot
|
||||||
# TODO: make it not just kill the bot
|
# TODO: make it not just kill the bot
|
||||||
sys.exit()
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -118,6 +118,7 @@ class ParseThread(threading.Thread):
|
||||||
self.output_queue = output_queue # lines to be sent out
|
self.output_queue = output_queue # lines to be sent out
|
||||||
self.parsed_queue = parsed_queue # lines that have been parsed
|
self.parsed_queue = parsed_queue # lines that have been parsed
|
||||||
|
|
||||||
|
self.daemon = True
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -171,11 +172,9 @@ class IRCConnection(object):
|
||||||
self.socket.connect((self.host, self.port))
|
self.socket.connect((self.host, self.port))
|
||||||
|
|
||||||
self.receive_thread = ReceiveThread(self.socket, self.input_queue, self.timeout)
|
self.receive_thread = ReceiveThread(self.socket, self.input_queue, self.timeout)
|
||||||
self.receive_thread.daemon = True
|
|
||||||
self.receive_thread.start()
|
self.receive_thread.start()
|
||||||
|
|
||||||
self.send_thread = SendThread(self.socket, self.conn_name, self.output_queue)
|
self.send_thread = SendThread(self.socket, self.conn_name, self.output_queue)
|
||||||
self.send_thread.daemon = True
|
|
||||||
self.send_thread.start()
|
self.send_thread.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -116,12 +116,12 @@ class PluginLoader(object):
|
||||||
for plugin in self.bot.plugins['command']:
|
for plugin in self.bot.plugins['command']:
|
||||||
name = plugin[1]['name'].lower()
|
name = plugin[1]['name'].lower()
|
||||||
if not re.match(r'^\w+$', name):
|
if not re.match(r'^\w+$', name):
|
||||||
self.bot.logger.error('Invalid command name: "{}"" ({})'.format(name, format_plug(plugin)))
|
self.bot.logger.error('Invalid command name: "{}" ({})'.format(name, format_plug(plugin)))
|
||||||
continue
|
continue
|
||||||
if name in self.bot.commands:
|
if name in self.bot.commands:
|
||||||
print "### ERROR: command '{}' already registered ({}, {})".format(name,
|
self.bot.logger.error('Command already registered: "{}" ({}, {})'.format(name,
|
||||||
format_plug(self.bot.commands[name]),
|
format_plug(self.bot.commands[name]),
|
||||||
format_plug(plugin))
|
format_plug(plugin)))
|
||||||
continue
|
continue
|
||||||
self.bot.commands[name] = plugin
|
self.bot.commands[name] = plugin
|
||||||
|
|
||||||
|
|
Reference in a new issue