diff --git a/main.py b/main.py index a4aa40c..924fa36 100755 --- a/main.py +++ b/main.py @@ -77,10 +77,11 @@ class Irc(): self.schedulePing() self.run() except (socket.error, classes.ProtocolError, ConnectionError) as e: - log.warning('(%s) Failed to connect to IRC: %s: %s', + log.warning('(%s) Disconnected from IRC: %s: %s', self.name, type(e).__name__, str(e)) self.disconnect() autoconnect = self.serverdata.get('autoconnect') + log.debug('(%s) Autoconnect delay set to %s seconds.', self.name, autoconnect) if autoconnect is not None and autoconnect >= 0: log.info('(%s) Going to auto-reconnect in %s seconds.', self.name, autoconnect) time.sleep(autoconnect) @@ -103,20 +104,14 @@ class Irc(): while (time.time() - self.lastping) < self.pingtimeout: log.debug('(%s) time_since_last_ping: %s', self.name, (time.time() - self.lastping)) log.debug('(%s) self.pingtimeout: %s', self.name, self.pingtimeout) - try: - data = self.socket.recv(2048).decode("utf-8") - buf += data - if not data: - break - while '\n' in buf: - line, buf = buf.split('\n', 1) - log.debug("(%s) <- %s", self.name, line) - proto.handle_events(self, line) - except (socket.error, classes.ProtocolError, ConnectionError) as e: - log.warning('(%s) Disconnected from IRC: %s: %s', - self.name, type(e).__name__, str(e)) + data = self.socket.recv(2048).decode("utf-8") + buf += data + if not data: break - self.disconnect() + while '\n' in buf: + line, buf = buf.split('\n', 1) + log.debug("(%s) <- %s", self.name, line) + proto.handle_events(self, line) def send(self, data): # Safeguard against newlines in input!! Otherwise, each line gets diff --git a/plugins/relay.py b/plugins/relay.py index 2531382..a48895c 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -684,6 +684,7 @@ def initializeAll(irc): for link in entrydata['links']: network, channel = link initializeChannel(irc, channel) + def main(): loadDB() utils.schedulers['relaydb'] = scheduler = sched.scheduler() @@ -693,3 +694,7 @@ def main(): thread = threading.Thread(target=scheduler.run) thread.daemon = True thread.start() + +def handle_endburst(irc, numeric, command, args): + initializeAll(irc) +utils.add_hook(handle_endburst, "ENDBURST") diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 1b38ef0..b4b593e 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -38,15 +38,14 @@ def spawnClient(irc, nick, ident='null', host='null', realhost=None, modes=set() realname = realname or irc.botdata['realname'] realhost = realhost or host raw_modes = utils.joinModes(modes) + u = irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname, + realhost=realhost, ip=ip, modes=modes) + irc.servers[server].users.append(uid) _send(irc, server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}" " {ts} {modes} + :{realname}".format(ts=ts, host=host, nick=nick, ident=ident, uid=uid, modes=raw_modes, ip=ip, realname=realname, realhost=realhost)) - # XXX Deduplicate the code here - u = irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname, - realhost=realhost, ip=ip, modes=modes) - irc.servers[server].users.append(uid) return u def joinClient(irc, client, channel):