Mercurial > libervia-backend
comparison src/core/sat_main.py @ 506:2e43c74815ad
plugin text commands: Text commands is a new plugin that bring IRC-like commands
- Text commands catch message sent, and check commands starting by /
- /nick command is managed
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 27 Sep 2012 00:54:42 +0200 |
parents | 65ecbb473cbb |
children | 862c0d6ab974 |
comparison
equal
deleted
inserted
replaced
505:2402668b5d05 | 506:2e43c74815ad |
---|---|
463 "to": jid.JID(to), | 463 "to": jid.JID(to), |
464 "message": msg, | 464 "message": msg, |
465 "subject": subject, | 465 "subject": subject, |
466 "type": mess_type | 466 "type": mess_type |
467 } | 467 } |
468 if not self.trigger.point("sendMessage", mess_data, profile): | 468 |
469 return | |
470 if mess_data["type"] == "auto": | 469 if mess_data["type"] == "auto": |
471 #XXX: if the type has not been changed by a trigger method, | 470 # we try to guess the type |
472 # we try to guess it | |
473 if mess_data["subject"]: | 471 if mess_data["subject"]: |
474 mess_data["type"] = 'normal' | 472 mess_data["type"] = 'normal' |
475 elif not mess_data["to"].resource: #if to JID has a resource, the type is not 'groupchat' | 473 elif not mess_data["to"].resource: #if to JID has a resource, the type is not 'groupchat' |
476 #we may have a groupchat message, we check if the we know this jid | 474 #we may have a groupchat message, we check if the we know this jid |
477 try: | 475 try: |
485 else: | 483 else: |
486 mess_data["type"] = 'chat' | 484 mess_data["type"] = 'chat' |
487 else: | 485 else: |
488 mess_data["type"] == 'chat' | 486 mess_data["type"] == 'chat' |
489 mess_data["type"] == "chat" if mess_data["subject"] else "normal" | 487 mess_data["type"] == "chat" if mess_data["subject"] else "normal" |
488 | |
489 if not self.trigger.point("sendMessage", mess_data, profile): | |
490 return | |
491 | |
490 debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to}) | 492 debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to}) |
491 message = domish.Element(('jabber:client','message')) | 493 message = domish.Element(('jabber:client','message')) |
492 message["to"] = mess_data["to"].full() | 494 message["to"] = mess_data["to"].full() |
493 message["from"] = current_jid.full() | 495 message["from"] = current_jid.full() |
494 message["type"] = mess_data["type"] | 496 message["type"] = mess_data["type"] |
495 if mess_data["subject"]: | 497 if mess_data["subject"]: |
496 message.addElement("subject", "jabber:client", subject) | 498 message.addElement("subject", "jabber:client", subject) |
497 message.addElement("body", "jabber:client", msg) | 499 message.addElement("body", "jabber:client", mess_data["message"]) |
498 client.xmlstream.send(message) | 500 client.xmlstream.send(message) |
499 if mess_data["type"]!="groupchat": | 501 if mess_data["type"]!="groupchat": |
500 self.memory.addToHistory(current_jid, jid.JID(to), unicode(msg), profile=profile) #we don't add groupchat message to history, as we get them back | 502 self.memory.addToHistory(current_jid, jid.JID(to), unicode(mess_data["message"]), profile=profile) #we don't add groupchat message to history, as we get them back |
501 #and they will be added then | 503 #and they will be added then |
502 self.bridge.newMessage(message['from'], unicode(msg), mess_type=mess_data["type"], to_jid=message['to'], profile=profile) #We send back the message, so all clients are aware of it | 504 self.bridge.newMessage(message['from'], unicode(mess_data["message"]), mess_type=mess_data["type"], to_jid=message['to'], profile=profile) #We send back the message, so all clients are aware of it |
503 | 505 |
504 | 506 |
505 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'): | 507 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'): |
506 """Send our presence information""" | 508 """Send our presence information""" |
507 profile = self.memory.getProfileName(profile_key) | 509 profile = self.memory.getProfileName(profile_key) |