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
|
||||
log_name = "bot.log"
|
||||
fh = logging.FileHandler(log_name)
|
||||
fh.setLevel(logging.DEBUG)
|
||||
fh.setLevel(logging.INFO)
|
||||
|
||||
# stdout handler
|
||||
sh = logging.StreamHandler()
|
||||
|
|
|
@ -106,7 +106,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)
|
||||
|
|
16
core/main.py
16
core/main.py
|
@ -53,7 +53,7 @@ class Input(dict):
|
|||
self[key] = value
|
||||
|
||||
|
||||
def run(func, input, bot):
|
||||
def run(bot, func, input):
|
||||
args = func._args
|
||||
|
||||
uses_db = 'db' in args and 'db' not in input
|
||||
|
@ -72,17 +72,20 @@ def run(func, input, bot):
|
|||
out = func(input.inp, **input)
|
||||
except:
|
||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||
return
|
||||
else:
|
||||
kw = dict((key, input[key]) for key in args if key in input)
|
||||
try:
|
||||
out = func(input.inp, **kw)
|
||||
except:
|
||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||
return
|
||||
else:
|
||||
try:
|
||||
out = func(input.inp)
|
||||
except:
|
||||
bot.logger.exception("Error in plugin {}:".format(func._filename))
|
||||
return
|
||||
if out is not None:
|
||||
input.reply(unicode(out))
|
||||
|
||||
|
@ -95,8 +98,7 @@ def do_sieve(sieve, bot, input, func, type, args):
|
|||
try:
|
||||
return sieve(bot, input, func, type, args)
|
||||
except Exception:
|
||||
print 'sieve error',
|
||||
traceback.print_exc()
|
||||
bot.logger.exception("Error in sieve {}:".format(func._filename))
|
||||
return None
|
||||
|
||||
|
||||
|
@ -118,12 +120,12 @@ class Handler(object):
|
|||
break
|
||||
|
||||
if uses_db:
|
||||
input.db = self.bot.db
|
||||
input.db = None
|
||||
|
||||
try:
|
||||
run(self.func, input)
|
||||
run(self.bot, self.func, input)
|
||||
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):
|
||||
self.input_queue.put(StopIteration)
|
||||
|
@ -145,7 +147,7 @@ def dispatch(bot, input, kind, func, args, autohelp=False):
|
|||
if func._thread:
|
||||
bot.threads[func].put(input)
|
||||
else:
|
||||
thread.start_new_thread(run, (func, input, bot))
|
||||
thread.start_new_thread(run, (bot, func, input))
|
||||
|
||||
|
||||
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'))
|
||||
|
||||
print out
|
||||
bot.logger.debug(out)
|
||||
|
|
Reference in a new issue