Mercurial > xib
comparison bridge.py @ 18:3cdf7bb580da
Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Thu, 20 Aug 2009 01:57:51 +0200 |
parents | 32a35f7eff70 |
children | c1b84196c100 |
comparison
equal
deleted
inserted
replaced
17:32a35f7eff70 | 18:3cdf7bb580da |
---|---|
52 self.irc_connection.connect(nick_callback=self._irc_nick_callback) | 52 self.irc_connection.connect(nick_callback=self._irc_nick_callback) |
53 except: | 53 except: |
54 self.bot.error('Error: joining IRC room failed') | 54 self.bot.error('Error: joining IRC room failed') |
55 raise | 55 raise |
56 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode') | 56 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode') |
57 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode') | |
58 | 57 |
59 | 58 |
60 def _irc_nick_callback(self, error, arguments=[]): | 59 def _irc_nick_callback(self, error, arguments=[]): |
61 if error == None: | 60 if error == None: |
62 self.irc_connection.join(self.irc_room) | 61 self.irc_connection.join(self.irc_room) |
63 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) | 62 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) |
63 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) | |
64 if error == 'nicknameinuse': | 64 if error == 'nicknameinuse': |
65 self.bot.error('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') | 65 self.bot.error('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') |
66 raise Exception('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') | 66 raise Exception('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') |
67 elif error == 'erroneusnickname': | 67 elif error == 'erroneusnickname': |
68 self.bot.error('Error: "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') | 68 self.bot.error('Error: "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') |
74 | 74 |
75 def _xmpp_join_callback(self, errors): | 75 def _xmpp_join_callback(self, errors): |
76 """Called by muc._xmpp_presence_handler""" | 76 """Called by muc._xmpp_presence_handler""" |
77 if len(errors) == 0: | 77 if len(errors) == 0: |
78 self.bot.error('===> Debug: succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) | 78 self.bot.error('===> Debug: succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) |
79 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) | |
79 for error in errors: | 80 for error in errors: |
80 try: | 81 try: |
81 raise error | 82 raise error |
82 except xmpp.muc.NicknameConflict: | 83 except xmpp.muc.NicknameConflict: |
83 self.bot.error('Error: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') | 84 self.bot.error('Error: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') |
121 def get_participants_nicknames_list(self, protocols=['irc', 'xmpp']): | 122 def get_participants_nicknames_list(self, protocols=['irc', 'xmpp']): |
122 """Returns a list of the nicknames of the bridge's participants that are connected on the XMPP side.""" | 123 """Returns a list of the nicknames of the bridge's participants that are connected on the XMPP side.""" |
123 participants_nicknames = [] | 124 participants_nicknames = [] |
124 for p in self.participants: | 125 for p in self.participants: |
125 if p.protocol in protocols: | 126 if p.protocol in protocols: |
126 participants_nicknames.append(p.nickname) | 127 participants_nicknames.append('"'+p.nickname+'"') |
127 return participants_nicknames | 128 return participants_nicknames |
128 | 129 |
129 | 130 |
130 def removeParticipant(self, left_protocol, nickname, leave_message): | 131 def removeParticipant(self, left_protocol, nickname, leave_message): |
131 """Remove the participant using nickname from the bridge. Raises a NoSuchParticipantException if nickname is not used in the bridge.""" | 132 """Remove the participant using nickname from the bridge. Raises a NoSuchParticipantException if nickname is not used in the bridge.""" |