#bots = {'erebus': bot.Bot(nick='Erebus', user='erebus', bind='', server='irc.quakenet.org', port=6667, realname='Erebus')}
class Bot(object):
def __init__(self, parent, nick, user, bind, authname, authpass, server, port, realname):
+ self.maxlen = 510
+
self.parent = parent
self.nick = nick
self.permnick = nick
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 recvq (510) because of the length the server adds on about the source (us).
+ # 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.conn.recvq
- - 63 # max hostname len
- - 11 # max ident len
- - 3 # the symbols in :nick!user@host
- - len(self.nick)
- )
+ maxlen = self.maxmsglen()
if len(cmd) > maxlen:
if not truncate:
return False
def quit(self, reason="Shutdown"):
self.conn.send("QUIT :%s" % (reason))
+ def maxmsglen(self):
+ return (
+ self.maxlen
+ - 63 # max hostname len
+ - 11 # max ident len
+ - 3 # the symbols in :nick!user@host
+ - len(self.nick)
+ )
+
def __str__(self): return self.nick
def __repr__(self): return "<Bot %r>" % (self.nick)
self.state = 0 # 0=disconnected, 1=registering, 2=connected
self.bytessent = 0
- self.recvq = 510
+ self.recvq = 510 # How much we can send per period
self.exceeded = False
self._nowrite = False