This commit is contained in:
Luke Rogers 2013-11-09 20:31:16 +13:00
parent fbb6204f83
commit 926b8c3f05
2 changed files with 18 additions and 15 deletions

View file

@ -31,19 +31,19 @@ def exit_gracefully(signum, frame):
original_sigint = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, exit_gracefully)
# create new bot object
# create a bot thread and start it
cloudbot = bot.Bot()
cloudbot.start()
cloudbot.run()
# wait for the bot loop to stop
if cloudbot.do_restart:
# this kills the bot
# TODO: make it not just kill the bot
time.sleep(2)
sys.exit()
else:
print "wtf"
time.sleep(2)
sys.exit()
# watch to see if the bot stops running or needs a restart
while True:
if cloudbot.running:
time.sleep(.1)
else:
if cloudbot.do_restart:
# create a new bot thread and start it
cloudbot = bot.Bot()
cloudbot.start()
continue
else:
break

View file

@ -4,6 +4,7 @@ import re
import os
import Queue
import collections
import threading
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import create_engine
@ -45,7 +46,7 @@ def get_logger():
return logger
class Bot(object):
class Bot(threading.Thread):
def __init__(self):
# basic variables
self.start_time = time.time()
@ -71,6 +72,8 @@ class Bot(object):
self.loader = PluginLoader(self)
threading.Thread.__init__(self)
def run(self):
"""recieves input from the IRC engine and processes it"""