Mercurial > xib
comparison bridge.py @ 219:63289aa1dea7
moved "nicknametoolong" and ServerConnection.really_connected handling to irclib, renamed ServerConnection.really_connected to .logged_in
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 07 Mar 2010 12:08:29 +0100 |
parents | d527d7b75f56 |
children | 1a82d5d40d90 |
comparison
equal
deleted
inserted
replaced
218:ca22fdea1c17 | 219:63289aa1dea7 |
---|---|
73 def _join_irc_failed(self, reason): | 73 def _join_irc_failed(self, reason): |
74 self.bot.error(say_levels.error, 'failed to connect to the IRC chan of bridge '+str(self)+'\nreason: '+reason, send_to_admins=True) | 74 self.bot.error(say_levels.error, 'failed to connect to the IRC chan of bridge '+str(self)+'\nreason: '+reason, send_to_admins=True) |
75 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False) | 75 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False) |
76 | 76 |
77 | 77 |
78 def _irc_nick_callback(self, error, arguments=[]): | 78 def _irc_nick_callback(self, error): |
79 if error == None: | 79 if error == None: |
80 if self.mode == None: | 80 if self.mode == None: |
81 return | 81 return |
82 self.irc_connection.join(self.irc_room) | 82 self.irc_connection.join(self.irc_room) |
83 self.bot.error(3, 'successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) | 83 self.bot.error(3, 'successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) |
90 if error in ['nicknameinuse', 'nickcollision']: | 90 if error in ['nicknameinuse', 'nickcollision']: |
91 reason = '"'+self.bot.nickname+'" is already used or reserved on the IRC server' | 91 reason = '"'+self.bot.nickname+'" is already used or reserved on the IRC server' |
92 elif error == 'erroneusnickname': | 92 elif error == 'erroneusnickname': |
93 reason = '"'+self.bot.nickname+'" got "erroneusnickname"' | 93 reason = '"'+self.bot.nickname+'" got "erroneusnickname"' |
94 elif error == 'nicknametoolong': | 94 elif error == 'nicknametoolong': |
95 reason = '"'+self.bot.nickname+'" got "nicknametoolong", limit seems to be '+str(arguments[0]) | 95 reason = '"'+self.bot.nickname+'" got "nicknametoolong", limit seems to be '+str(len(self.irc_connection.real_nickname)) |
96 else: | 96 else: |
97 reason = error | 97 reason = error |
98 self._join_irc_failed(reason) | 98 self._join_irc_failed(reason) |
99 | 99 |
100 | 100 |
133 self.bot.error(3, 'not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True) | 133 self.bot.error(3, 'not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True) |
134 return | 134 return |
135 try: | 135 try: |
136 p = self.get_participant(nickname) | 136 p = self.get_participant(nickname) |
137 if p.protocol != from_protocol: | 137 if p.protocol != from_protocol: |
138 if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True and p.irc_connection.real_nickname == nickname or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc) and p.xmpp_c.nickname == nickname: | 138 if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.logged_in and p.irc_connection.real_nickname == nickname or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc) and p.xmpp_c.nickname == nickname: |
139 if irc_id: | 139 if irc_id: |
140 p.irc_connection.irc_id = irc_id | 140 p.irc_connection.irc_id = irc_id |
141 return p | 141 return p |
142 p.set_both_sides() | 142 p.set_both_sides() |
143 return p | 143 return p |
378 def _say_on_xmpp(self, message): | 378 def _say_on_xmpp(self, message): |
379 self.xmpp_room.say(message) | 379 self.xmpp_room.say(message) |
380 | 380 |
381 | 381 |
382 def show_participants_list_on(self, protocols=[]): | 382 def show_participants_list_on(self, protocols=[]): |
383 if 'irc' in protocols and self.irc_connection.really_connected: | 383 if 'irc' in protocols and self.irc_connection.logged_in: |
384 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) | 384 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) |
385 self.say(say_levels.info, 'Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) | 385 self.say(say_levels.info, 'Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) |
386 if 'xmpp' in protocols: | 386 if 'xmpp' in protocols: |
387 irc_participants_nicknames = self.get_participants_nicknames_list(protocols=['irc']) | 387 irc_participants_nicknames = self.get_participants_nicknames_list(protocols=['irc']) |
388 self.say(say_levels.info, 'Participants on IRC: '+' '.join(irc_participants_nicknames), on_irc=False) | 388 self.say(say_levels.info, 'Participants on IRC: '+' '.join(irc_participants_nicknames), on_irc=False) |