comparison participant.py @ 95:f27de569f5db

Improved /me handling Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Tue, 29 Sep 2009 19:35:57 +0200
parents 810a6bed6c9c
children 35e0ddf3b13c
comparison
equal deleted inserted replaced
94:810a6bed6c9c 95:f27de569f5db
157 self.createDuplicateOnXMPP() 157 self.createDuplicateOnXMPP()
158 158
159 159
160 def sayOnIRC(self, message): 160 def sayOnIRC(self, message):
161 try: 161 try:
162 bot_say = False
163 if message[:4] == '/me ':
164 action = True
165 message = message[4:]
166 else:
167 action = False
162 if isinstance(self.irc_connection, ServerConnection): 168 if isinstance(self.irc_connection, ServerConnection):
163 try: 169 try:
164 if message[:4] == '/me ': 170 if action:
165 self.irc_connection.action(self.bridge.irc_room, message[4:]) 171 self.irc_connection.action(self.bridge.irc_room, message)
166 else: 172 else:
167 self.irc_connection.privmsg(self.bridge.irc_room, message) 173 self.irc_connection.privmsg(self.bridge.irc_room, message)
168 except ServerNotConnectedError: 174 except ServerNotConnectedError:
175 bot_say = True
176 elif not isinstance(self.xmpp_c, xmpp.client.Client):
177 bot_say = True
178 if bot_say:
179 if action:
180 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message)
181 else:
169 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) 182 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
170 elif not isinstance(self.xmpp_c, xmpp.client.Client):
171 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
172 except EncodingException: 183 except EncodingException:
173 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 184 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
174 185
175 186
176 def sayOnIRCTo(self, to, message): 187 def sayOnIRCTo(self, to, message):
189 def sayOnXMPP(self, message): 200 def sayOnXMPP(self, message):
190 try: 201 try:
191 if isinstance(self.xmpp_c, xmpp.client.Client): 202 if isinstance(self.xmpp_c, xmpp.client.Client):
192 self.muc.say(auto_decode(message)) 203 self.muc.say(auto_decode(message))
193 elif not isinstance(self.irc_connection, ServerConnection): 204 elif not isinstance(self.irc_connection, ServerConnection):
194 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message)) 205 if message[:4] == '/me ':
206 self.bridge.xmpp_room.say('* '+self.nickname+' '+auto_decode(message[4:]))
207 else:
208 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message))
195 except EncodingException: 209 except EncodingException:
196 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 210 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
197 211
198 212
199 def sayOnXMPPTo(self, to, message): 213 def sayOnXMPPTo(self, to, message):