Fix stuff
Specifically, fix the connection (so the bot actually gets messages, damn), include message output in logs, and fix a crash bug
This commit is contained in:
parent
5616e54bcf
commit
b9b21d9ae8
13
bot.py
13
bot.py
|
@ -28,13 +28,14 @@ say_log("...and BBJ is all set up!")
|
|||
trigger = lambda x: "{}: ".format(x)
|
||||
log = lambda x,e: e[len(trigger(x)):]
|
||||
|
||||
class AuditBot(teambot.Handler,teambot.CommandHandlerMixin):
|
||||
def handle_command(self,target,nick,text):
|
||||
class AuditBot(teambot.Handler):
|
||||
def on_pubmsg(self,target,nick,text):
|
||||
nick = nick.split("|")[0]
|
||||
if nick in opts.get("sudoers") and text.startswith(trigger(self.bot.bot_nick)):
|
||||
say_log("{} is auditing \"{}\"".format(nick,log(self.bot.bot_nick,text)))
|
||||
r = bbj.thread_reply(opts.get("thread_id"),opts.get("format").format(time.strftime("%Y-%m-%d %H:%M:%S"),nick,log(self.bot.bot_nick,text)))
|
||||
say_log(repr(r))
|
||||
say_log("[{}] {}: {}".format(target,nick,text))
|
||||
if nick in opts.get("sudoers") and text.startswith(trigger(self._bot.bot_nick)):
|
||||
say_log("{} is auditing \"{}\"".format(nick,log(self._bot.bot_nick,text)),"!","green")
|
||||
bbj.thread_reply(opts.get("thread_id"),opts.get("format").format(time.strftime("%Y-%m-%d %H:%M:%S"),nick,log(self._bot.bot_nick,text)))
|
||||
# say_log(repr(r))
|
||||
|
||||
if __name__=="__main__":
|
||||
channels = "#sudoers".split()
|
||||
|
|
Reference in New Issue