def start(self): log.info('Mainloop started!') self.start_loop_threads() try: for line in self.recieve_line(): log.debug('<<' + line) self.parse_line(line) except KeyboardInterrupt: self.stop_loop_threads() self.disconnect('Interrupted') except ConnectionResetError: self.stop_loop_threads() log.critical('connection reset by peer')
def handle_not_host(self, not_host, parts): type_ = not_host parts[0] = parts[0][1:] msg = ' '.join(parts) if type_ == 'ERROR': if msg == 'Your host is trying to (re)connect too fast -- throttled': log.critical('Reconnecting too fast!') self.disconnect() elif msg.startswith('Closing Link'): log.critical('Server closed link!') self.disconnect() elif type_ == 'PING': self.pong(msg)
def run(self): while not self.e.wait(self.delay): try: irc.loops.fire(self.event, self.bot) except: log.critical('error in "' + self.event + '"-thread!') log.critical('-----') log.critical(traceback.format_exc()) log.critical('-----')