refresh works vaugely better
This commit is contained in:
parent
bdce09435a
commit
4c5087773d
4 changed files with 12 additions and 10 deletions
|
@ -28,7 +28,7 @@ def get_logger():
|
||||||
# add a file handler
|
# add a file handler
|
||||||
log_name = "bot.log"
|
log_name = "bot.log"
|
||||||
fh = logging.FileHandler(log_name)
|
fh = logging.FileHandler(log_name)
|
||||||
fh.setLevel(logging.DEBUG)
|
fh.setLevel(logging.INFO)
|
||||||
|
|
||||||
# stdout handler
|
# stdout handler
|
||||||
sh = logging.StreamHandler()
|
sh = logging.StreamHandler()
|
||||||
|
|
|
@ -106,7 +106,7 @@ class SendThread(threading.Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
while not self.shutdown:
|
while not self.shutdown:
|
||||||
line = self.output_queue.get().splitlines()[0][:500]
|
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'
|
self.output_buffer += line.encode('utf-8', 'replace') + '\r\n'
|
||||||
while self.output_buffer:
|
while self.output_buffer:
|
||||||
sent = self.socket.send(self.output_buffer)
|
sent = self.socket.send(self.output_buffer)
|
||||||
|
|
16
core/main.py
16
core/main.py
|
@ -53,7 +53,7 @@ class Input(dict):
|
||||||
self[key] = value
|
self[key] = value
|
||||||
|
|
||||||
|
|
||||||
def run(func, input, bot):
|
def run(bot, func, input):
|
||||||
args = func._args
|
args = func._args
|
||||||
|
|
||||||
uses_db = 'db' in args and 'db' not in input
|
uses_db = 'db' in args and 'db' not in input
|
||||||
|
@ -72,17 +72,20 @@ def run(func, input, bot):
|
||||||
out = func(input.inp, **input)
|
out = func(input.inp, **input)
|
||||||
except:
|
except:
|
||||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
kw = dict((key, input[key]) for key in args if key in input)
|
kw = dict((key, input[key]) for key in args if key in input)
|
||||||
try:
|
try:
|
||||||
out = func(input.inp, **kw)
|
out = func(input.inp, **kw)
|
||||||
except:
|
except:
|
||||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
out = func(input.inp)
|
out = func(input.inp)
|
||||||
except:
|
except:
|
||||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||||
|
return
|
||||||
if out is not None:
|
if out is not None:
|
||||||
input.reply(unicode(out))
|
input.reply(unicode(out))
|
||||||
|
|
||||||
|
@ -95,8 +98,7 @@ def do_sieve(sieve, bot, input, func, type, args):
|
||||||
try:
|
try:
|
||||||
return sieve(bot, input, func, type, args)
|
return sieve(bot, input, func, type, args)
|
||||||
except Exception:
|
except Exception:
|
||||||
print 'sieve error',
|
bot.logger.exception("Error in sieve {}:".format(func._filename))
|
||||||
traceback.print_exc()
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,12 +120,12 @@ class Handler(object):
|
||||||
break
|
break
|
||||||
|
|
||||||
if uses_db:
|
if uses_db:
|
||||||
input.db = self.bot.db
|
input.db = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run(self.func, input)
|
run(self.bot, self.func, input)
|
||||||
except:
|
except:
|
||||||
self.bot.logger.exception("Error in plugin {}:".format(self.Sfunc._filename))
|
self.bot.logger.exception("Error in plugin {}:".format(self.func._filename))
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.input_queue.put(StopIteration)
|
self.input_queue.put(StopIteration)
|
||||||
|
@ -145,7 +147,7 @@ def dispatch(bot, input, kind, func, args, autohelp=False):
|
||||||
if func._thread:
|
if func._thread:
|
||||||
bot.threads[func].put(input)
|
bot.threads[func].put(input)
|
||||||
else:
|
else:
|
||||||
thread.start_new_thread(run, (func, input, bot))
|
thread.start_new_thread(run, (bot, func, input))
|
||||||
|
|
||||||
|
|
||||||
def match_command(bot, command):
|
def match_command(bot, command):
|
||||||
|
|
|
@ -113,4 +113,4 @@ def log(paraml, input=None, bot=None):
|
||||||
|
|
||||||
out = "{} {} {}".format(timestamp, input.chan, beau.encode('utf8', 'ignore'))
|
out = "{} {} {}".format(timestamp, input.chan, beau.encode('utf8', 'ignore'))
|
||||||
|
|
||||||
print out
|
bot.logger.debug(out)
|
||||||
|
|
Reference in a new issue