# HG changeset patch # User Charly COSTE # Date 1263995332 -3600 # Node ID 0fc24e232997ce182748de85d5497aaac5c63bda # Parent 12d564cd0203d9049491941354a8cf79609a6126 some fixes related to IRC nicknames Signed-off-by: Charly COSTE diff --git a/bot.py b/bot.py --- a/bot.py +++ b/bot.py @@ -451,7 +451,7 @@ class Bot(threading.Thread): # Events we always want to ignore - if 'all' in event.eventtype() or 'motd' in event.eventtype(): + if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse', 'nickcollision', 'erroneusnickname']: return if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo', '328']: self.error('=> Debug: ignoring IRC '+event.eventtype(), debug=True) @@ -663,25 +663,8 @@ class Bot(threading.Thread): return - # From here the event is shown - self.error(event_str, debug=True) - - - # Nickname callbacks - # TODO: move this into irclib.py - if event.eventtype() == 'nicknameinuse': - connection._call_nick_callbacks('nicknameinuse', arguments=[event]) - return - if event.eventtype() == 'nickcollision': - connection._call_nick_callbacks('nickcollision', arguments=[event]) - return - if event.eventtype() == 'erroneusnickname': - connection._call_nick_callbacks('erroneusnickname', arguments=[event]) - return - - # Unhandled events - self.error('=> Debug: event not handled', debug=True) + self.error(event_str+'\n=> Debug: event not handled', debug=True) def _send_message_to_admins(self, message): diff --git a/irclib.py b/irclib.py --- a/irclib.py +++ b/irclib.py @@ -700,6 +700,8 @@ class ServerConnection(Connection): def _handle_event(self, event): """[Internal]""" self.irclibobj._handle_event(self, event) + if event.eventtype() in ['disconnect', 'nicknameinuse', 'nickcollision', 'erroneusnickname']: + self._call_nick_callbacks(event.eventtype(), arguments=[event]) if event.eventtype() in self.handlers: for fn in self.handlers[event.eventtype()]: fn(self, event) @@ -840,7 +842,7 @@ class ServerConnection(Connection): """Send a NICK command.""" if callback != None: self.add_nick_callback(callback) - if re.search('[ \.]', newnick) != None: + if re.search('[ \.\']', newnick) != None: self._call_nick_callbacks('erroneusnickname') return False try: