comparison participant.py @ 26:1691ab4d131f

Fixed participant's "say" functions. Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Fri, 21 Aug 2009 00:25:42 +0200
parents c1b84196c100
children a694ffe6a973
comparison
equal deleted inserted replaced
25:a9066c416533 26:1691ab4d131f
118 else: 118 else:
119 self.createDuplicateOnXMPP() 119 self.createDuplicateOnXMPP()
120 120
121 121
122 def sayOnIRC(self, message): 122 def sayOnIRC(self, message):
123 if self.protocol == 'irc':
124 raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
125
126 try: 123 try:
127 if self.irc_connection == None: 124 if self.irc_connection != None:
125 self.irc_connection.privmsg(self.bridge.irc_room, message)
126 elif self.xmpp_c == None:
128 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) 127 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
129 else:
130 self.irc_connection.privmsg(self.bridge.irc_room, message)
131 except EncodingException: 128 except EncodingException:
132 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 129 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
133 130
134 131
135 def sayOnIRCTo(self, to, message): 132 def sayOnIRCTo(self, to, message):
136 if self.protocol == 'irc': 133 if self.irc_connection != None:
137 raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
138
139 if self.irc_connection == None:
140 if self.bridge.mode != 'normal':
141 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in limited mode.')
142 else:
143 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
144 else:
145 try: 134 try:
146 self.irc_connection.privmsg(to, message) 135 self.irc_connection.privmsg(to, message)
147 except EncodingException: 136 except EncodingException:
148 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 137 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
138 elif self.xmpp_c == None:
139 if self.bridge.mode != 'normal':
140 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
141 else:
142 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.')
149 143
150 144
151 def sayOnXMPP(self, message): 145 def sayOnXMPP(self, message):
152 if self.protocol == 'xmpp':
153 raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
154
155 try: 146 try:
156 if self.xmpp_c == None: 147 if self.xmpp_c != None:
148 self.muc.say(auto_decode(message))
149 elif self.irc_connection == None:
157 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message)) 150 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message))
158 else:
159 self.muc.say(auto_decode(message))
160 except EncodingException: 151 except EncodingException:
161 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 152 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
162 153
163 154
164 def sayOnXMPPTo(self, to, message): 155 def sayOnXMPPTo(self, to, message):
165 if self.protocol == 'xmpp':
166 raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
167
168 try: 156 try:
169 self.muc.sayTo(to, auto_decode(message)) 157 if self.xmpp_c != None:
158 self.muc.sayTo(to, auto_decode(message))
159 elif self.irc_connection == None:
160 if self.bridge.mode != 'normal':
161 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
162 else:
163 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.')
170 except EncodingException: 164 except EncodingException:
171 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 165 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
172 166
173 167
174 def leave(self, message): 168 def leave(self, message):