Ejemplo n.º 1
0
 def handle_event(self, msg, send, c, e):
     passwd = self.config['auth']['serverpass']
     user = self.config['core']['nick']
     # The SASL Successful event doesn't have a pretty name.
     if e.type == '903':
         if msg == 'SASL authentication successful':
             self.connection.cap('END')
     elif e.type == 'authenticate':
         if e.target == '+':
             token = base64.b64encode('\0'.join([user, user, passwd]).encode())
             self.connection.send_raw('AUTHENTICATE %s' % token.decode())
     elif e.type == 'bannedfromchan':
         self.workers.defer(5, False, self.do_rejoin, c, e)
     elif e.type == 'cap':
         if msg == 'ACK sasl':
             self.connection.send_raw('AUTHENTICATE PLAIN')
     elif e.type in ['ctcpreply', 'nosuchnick']:
         misc.ping(self.ping_map, c, e, time.time())
     elif e.type == 'error':
         logging.error(e.target)
     elif e.type == 'nick':
         for channel in misc.get_channels(self.channels, e.target):
             self.do_log(channel, e.source.nick, e.target, 'nick')
         if self.config.getboolean('feature', 'nickserv') and e.target in self.admins:
             c.privmsg('NickServ', 'ACC %s' % e.target)
         if identity.handle_nick(self, e):
             for x in misc.get_channels(self.channels, e.target):
                 self.do_kick(send, x, e.target, "identity crisis")
     elif e.type == 'nicknameinuse':
         self.connection.nick('Guest%d' % random.getrandbits(20))
         if self.config.getboolean('feature', 'nickserv'):
             self.connection.privmsg('NickServ', 'REGAIN %s %s' % (user, passwd))
         self.workers.defer(5, False, self.do_welcome)
     elif e.type == 'privnotice':
         # FIXME: come up with a better way to prevent admin abuse.
         if e.source.nick == 'NickServ':
             admin.set_admin(msg, self)
     elif e.type == 'welcome':
         logging.info("Connected to server %s", self.config['core']['host'])
         self.do_welcome()
Ejemplo n.º 2
0
 def on_ctcpreply(self, c, e):
     if len(e.arguments) == 2:
         misc.ping(c, e, time())
Ejemplo n.º 3
0
 def on_ctcpreply(self, c, e):
     misc.ping(c, e, time())