comparison src/plugins/plugin_exp_parrot.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children beaf6bec2fcd
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
22 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
23 from twisted.words.protocols.jabber import jid 23 from twisted.words.protocols.jabber import jid
24 24
25 25
26 from sat.core.exceptions import UnknownEntityError 26 from sat.core.exceptions import UnknownEntityError
27 from sat.tools.misc import SkipOtherTriggers 27 from sat.tools.misc import SkipOtherTriggers
28 28
29 PLUGIN_INFO = { 29 PLUGIN_INFO = {
30 "name": "Parrot Plugin", 30 "name": "Parrot Plugin",
31 "import_name": "EXP-PARROT", 31 "import_name": "EXP-PARROT",
32 "type": "EXP", 32 "type": "EXP",
55 # client = self.host.getClient(profile) 55 # client = self.host.getClient(profile)
56 # try: 56 # try:
57 # _links = client.parrot_links 57 # _links = client.parrot_links
58 # except AttributeError: 58 # except AttributeError:
59 # return True 59 # return True
60 # 60 #
61 # if mess_data['to'].userhostJID() in _links.values(): 61 # if mess_data['to'].userhostJID() in _links.values():
62 # debug("Parrot link detected, skipping other triggers") 62 # debug("Parrot link detected, skipping other triggers")
63 # raise SkipOtherTriggers 63 # raise SkipOtherTriggers
64 64
65 def MessageReceivedTrigger(self, message, profile): 65 def MessageReceivedTrigger(self, message, profile):
66 """ Check if source is linked and repeat message, else do nothing """ 66 """ Check if source is linked and repeat message, else do nothing """
67 client = self.host.getClient(profile) 67 client = self.host.getClient(profile)
68 from_jid = jid.JID(message["from"]) 68 from_jid = jid.JID(message["from"])
69 69
70 try: 70 try:
71 _links = client.parrot_links 71 _links = client.parrot_links
72 except AttributeError: 72 except AttributeError:
73 return True 73 return True
74 74
75 if not from_jid.userhostJID() in _links: 75 if not from_jid.userhostJID() in _links:
76 return True 76 return True
77 77
78 for e in message.elements(): 78 for e in message.elements():
79 if e.name == "body": 79 if e.name == "body":
80 mess_body = e.children[0] if e.children else "" 80 mess_body = e.children[0] if e.children else ""
81 81
82 try: 82 try:
83 entity_type = self.host.memory.getEntityData(from_jid, ['type'], profile)["type"] 83 entity_type = self.host.memory.getEntityData(from_jid, ['type'], profile)["type"]
84 except (UnknownEntityError, KeyError): 84 except (UnknownEntityError, KeyError):
85 entity_type = "contact" 85 entity_type = "contact"
86 if entity_type == 'chatroom': 86 if entity_type == 'chatroom':
95 linked = _links[from_jid.userhostJID()] 95 linked = _links[from_jid.userhostJID()]
96 96
97 self.host.sendMessage(unicode(linked), msg, None, "auto", profile_key=profile) 97 self.host.sendMessage(unicode(linked), msg, None, "auto", profile_key=profile)
98 else: 98 else:
99 warning("No body element found in message, following normal behaviour") 99 warning("No body element found in message, following normal behaviour")
100 100
101 return True 101 return True
102 102
103 def addParrot(self, source_jid, dest_jid, profile): 103 def addParrot(self, source_jid, dest_jid, profile):
104 """Add a parrot link from one entity to another one 104 """Add a parrot link from one entity to another one
105 @param source_jid: entity from who messages will be repeated 105 @param source_jid: entity from who messages will be repeated