+ rancmd = True
+ try:
+ cbret = callback(self, user, chan, target, *pieces[1:])
+ if isinstance(cbret, stringbase):
+ self.reply(target, user, cbret)
+ except Exception:
+ self.msg(user, "Command failed. Code: CBEXC%09.3f" % (time.time() % 100000))
+ self._cbexception("hook", user=user, target=target, msg=msg)
+ except SystemExit as e:
+ self.parent.mustquit = e
+ try:
+ curs = self.parent.query("UPDATE bots SET connected = 0")
+ curs.close()
+ except: pass
+ raise e
+ else:
+ rancmd = True
+ self.msg(user, "I don't know that command.")
+ if not rancmd:
+ self.msg(user, "You don't have enough access to run that command.")
+
+ def __debug_nomsg(self, target, msg):
+ if self.parent.cfg.getboolean('debug', 'nomsg'):
+ self.conn.send("PRIVMSG %s :%09.3f \ 34\1f!!! NOMSG\1f\ 3 %r, %r" % (self.parent.cfg.get('debug', 'owner'), time.time() % 100000, target, msg))
+ self.log('!', "!!! NOMSG")
+# print "%09.3f %s [!] %s" % (time.time() % 100000, self.nick, "!!! NOMSG")
+ traceback.print_stack()
+
+
+ def reply(self, chan, user, msg):
+ if chan is not None and (isinstance(chan, self.parent.Channel) or (isinstance(chan, stringbase) and chan[0] == "#")):
+ self.msg(chan, "%s: %s" % (user, msg))
+ else:
+ self.msg(user, msg)
+
+ """
+ Does the work for msg/slowmsg/fastmsg. Uses the append_callback to append to the correct queue.
+
+ In the case of fastmsg, self.conn.exceeded may be True, however, in this case append_callback=self.conn.send, so it will still be sent immediately.
+ """
+ def _msg(self, target, msg, truncate, append_callback, msgtype):
+ if self.parent.cfg.getboolean('erebus', 'nofakelag'): append_callback = self.conn.send
+
+ cmd = self._formatmsg(target, msg, msgtype)
+ # The max length is much shorter than conn.maxlen (510) because of the length the server adds on about the source (us).
+ # If you know your hostmask, you can of course figure the exact length, but it's very difficult to reliably know your hostmask.
+ maxlen = self.maxmsglen()
+ if len(cmd) > maxlen:
+ if not truncate:
+ return False
+ else:
+ cmd = cmd[:maxlen]
+
+ if self.conn.exceeded or self.conn.bytessent+len(cmd) >= self.conn.recvq:
+ append_callback(cmd)
+ else:
+ self.conn.send(cmd)
+
+ self.conn.exceeded = True
+ return True