80uy79gfiy
This commit is contained in:
parent
5f6c280ba2
commit
1b1d3da823
3 changed files with 7 additions and 4 deletions
|
@ -13,6 +13,7 @@ def clean_name(n):
|
|||
"""strip all spaces and capitalization"""
|
||||
return re.sub('[^A-Za-z0-9_]+', '', n.replace(" ", "_"))
|
||||
|
||||
|
||||
def get_logger():
|
||||
"""create and return a new logger object"""
|
||||
# create logger
|
||||
|
@ -41,7 +42,6 @@ def get_logger():
|
|||
|
||||
|
||||
class Bot(object):
|
||||
|
||||
def __init__(self):
|
||||
# basic variables
|
||||
self.start_time = time.time()
|
||||
|
@ -146,4 +146,3 @@ class Bot(object):
|
|||
self.logger.debug("Logging engine stopped")
|
||||
logging.shutdown()
|
||||
sys.exit()
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class SendThread(threading.Thread):
|
|||
def run(self):
|
||||
while not self.shutdown:
|
||||
line = self.output_queue.get().splitlines()[0][:500]
|
||||
print u"[{}]: {}".format(self.conn_name, line)
|
||||
print u"{}>>> {}".format(self.conn_name, line)
|
||||
self.output_buffer += line.encode('utf-8', 'replace') + '\r\n'
|
||||
while self.output_buffer:
|
||||
sent = self.socket.send(self.output_buffer)
|
||||
|
|
|
@ -58,6 +58,7 @@ class PluginLoader(object):
|
|||
"""loads (or reloads) all valid plugins from a specified file"""
|
||||
filename = os.path.basename(path)
|
||||
|
||||
# compile the file and eval it in a namespace
|
||||
try:
|
||||
code = compile(open(path, 'U').read(), filename, 'exec')
|
||||
namespace = {}
|
||||
|
@ -66,16 +67,19 @@ class PluginLoader(object):
|
|||
traceback.print_exc()
|
||||
return
|
||||
|
||||
# remove plugins already loaded from this filename
|
||||
# remove plugins already loaded from this file
|
||||
for name, data in self.bot.plugins.iteritems():
|
||||
self.bot.plugins[name] = [x for x in data
|
||||
if x[0]._filename != filename]
|
||||
|
||||
# stop all currently running instances of the plugins from this file
|
||||
for func, handler in list(self.bot.threads.iteritems()):
|
||||
if func._filename == filename:
|
||||
handler.stop()
|
||||
del self.bot.threads[func]
|
||||
|
||||
# find objects with hooks in the plugin namespace
|
||||
# TODO: kill it with fire, kill it all
|
||||
for obj in namespace.itervalues():
|
||||
if hasattr(obj, '_hook'): # check for magic
|
||||
if obj._thread:
|
||||
|
|
Reference in a new issue