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
This commit is contained in:
Goffi 2012-09-27 00:54:42 +02:00
commit 4e40bead7c

View file

@ -465,11 +465,9 @@ class SAT(service.Service):
"subject": subject,
"type": mess_type
}
if not self.trigger.point("sendMessage", mess_data, profile):
return
if mess_data["type"] == "auto":
#XXX: if the type has not been changed by a trigger method,
# we try to guess it
# we try to guess the type
if mess_data["subject"]:
mess_data["type"] = 'normal'
elif not mess_data["to"].resource: #if to JID has a resource, the type is not 'groupchat'
@ -487,6 +485,10 @@ class SAT(service.Service):
else:
mess_data["type"] == 'chat'
mess_data["type"] == "chat" if mess_data["subject"] else "normal"
if not self.trigger.point("sendMessage", mess_data, profile):
return
debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to})
message = domish.Element(('jabber:client','message'))
message["to"] = mess_data["to"].full()
@ -494,12 +496,12 @@ class SAT(service.Service):
message["type"] = mess_data["type"]
if mess_data["subject"]:
message.addElement("subject", "jabber:client", subject)
message.addElement("body", "jabber:client", msg)
message.addElement("body", "jabber:client", mess_data["message"])
client.xmlstream.send(message)
if mess_data["type"]!="groupchat":
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
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
#and they will be added then
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
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
def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):