Mercurial > libervia-backend
comparison src/plugins/plugin_misc_text_commands.py @ 523:24c0d51449e7
plugin text commands: added _feedback method to send an answer to user
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Oct 2012 13:37:15 +0200 |
parents | b7577230a7c8 |
children | 9a3913fb0a6c |
comparison
equal
deleted
inserted
replaced
522:3446ce33247d | 523:24c0d51449e7 |
---|---|
75 if arg[-1] !='@': | 75 if arg[-1] !='@': |
76 return jid.JID(arg) | 76 return jid.JID(arg) |
77 return jid.JID(arg+service_jid) | 77 return jid.JID(arg+service_jid) |
78 return jid.JID(u"%s@%s" % (arg, service_jid)) | 78 return jid.JID(u"%s@%s" % (arg, service_jid)) |
79 | 79 |
80 def _feedBack(self, message, mess_data, profile): | |
81 """Give a message back to the user""" | |
82 if mess_data["type"] == 'groupchat': | |
83 _from = mess_data["to"].userhostJID() | |
84 else: | |
85 _from = self.host.getJidNStream(profile)[0] | |
86 | |
87 self.host.bridge.newMessage(unicode(mess_data["to"]), message, mess_data['type'], unicode(_from), {}, profile=profile) | |
88 | |
80 def cmd_nick(self, mess_data, profile): | 89 def cmd_nick(self, mess_data, profile): |
81 """change nickname""" | 90 """change nickname""" |
82 debug("Catched nick command") | 91 debug("Catched nick command") |
83 | 92 |
84 if mess_data['type'] != "groupchat": | 93 if mess_data['type'] != "groupchat": |
132 def cmd_part(self, mess_data, profile): | 141 def cmd_part(self, mess_data, profile): |
133 """just a synonym of /leave""" | 142 """just a synonym of /leave""" |
134 return self.cmd_leave(mess_data, profile) | 143 return self.cmd_leave(mess_data, profile) |
135 | 144 |
136 def cmd_title(self, mess_data, profile): | 145 def cmd_title(self, mess_data, profile): |
137 """Change room's subject""" | 146 """change room's subject""" |
138 debug("Catched title command") | 147 debug("Catched title command") |
139 | 148 |
140 if mess_data['type'] != "groupchat": | 149 if mess_data['type'] != "groupchat": |
141 #/leave command does nothing if we are not on a group chat | 150 #/leave command does nothing if we are not on a group chat |
142 info("Ignoring /title command on a non groupchat message") | 151 info("Ignoring /title command on a non groupchat message") |
163 except AttributeError: | 172 except AttributeError: |
164 help_str = '' | 173 help_str = '' |
165 spaces = (longuest - len(command)) * ' ' | 174 spaces = (longuest - len(command)) * ' ' |
166 help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str)) | 175 help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str)) |
167 | 176 |
168 if mess_data["type"] == 'groupchat': | |
169 _from = mess_data["to"].userhostJID() | |
170 else: | |
171 _from = self.host.getJidNStream(profile)[0] | |
172 | |
173 help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),) | 177 help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),) |
174 | 178 self._feedBack(help_mess, mess_data, profile) |
175 self.host.bridge.newMessage(unicode(mess_data["to"]), help_mess, mess_data['type'], unicode(_from), {}, profile=profile) | |
176 | |
177 | 179 |
178 | 180 |