Made the tail-viewing of a log-file threaded for maximum asynchronicity.

This commit is contained in:
Griatch 2016-04-07 23:22:26 +02:00
parent 5583a8d758
commit 4a58fcb9f1
2 changed files with 29 additions and 10 deletions

View file

@ -100,8 +100,9 @@ class ChannelCommand(command.Command):
if self.history_start is not None:
# Try to view history
log_file = channel.attributes.get("log_file", default="channel_%s.log" % channel.key)
self.msg("".join(line.split("[-]", 1)[1] if "[-]" in line else line
for line in tail_log_file(log_file, self.history_start, 20)))
send_msg = lambda lines: self.msg("".join(line.split("[-]", 1)[1]
if "[-]" in line else line for line in lines))
tail_log_file(log_file, self.history_start, 20, callback=send_msg)
else:
channel.msg(msg, senders=self.caller, online=True)