Mercurial > libervia-backend
changeset 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 | 3446ce33247d |
children | 0bb595eff25b |
files | src/plugins/plugin_misc_text_commands.py |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_text_commands.py Sun Oct 21 13:36:28 2012 +0200 +++ b/src/plugins/plugin_misc_text_commands.py Sun Oct 21 13:37:15 2012 +0200 @@ -77,6 +77,15 @@ return jid.JID(arg+service_jid) return jid.JID(u"%s@%s" % (arg, service_jid)) + def _feedBack(self, message, mess_data, profile): + """Give a message back to the user""" + if mess_data["type"] == 'groupchat': + _from = mess_data["to"].userhostJID() + else: + _from = self.host.getJidNStream(profile)[0] + + self.host.bridge.newMessage(unicode(mess_data["to"]), message, mess_data['type'], unicode(_from), {}, profile=profile) + def cmd_nick(self, mess_data, profile): """change nickname""" debug("Catched nick command") @@ -134,7 +143,7 @@ return self.cmd_leave(mess_data, profile) def cmd_title(self, mess_data, profile): - """Change room's subject""" + """change room's subject""" debug("Catched title command") if mess_data['type'] != "groupchat": @@ -165,14 +174,7 @@ spaces = (longuest - len(command)) * ' ' help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str)) - if mess_data["type"] == 'groupchat': - _from = mess_data["to"].userhostJID() - else: - _from = self.host.getJidNStream(profile)[0] - help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),) - - self.host.bridge.newMessage(unicode(mess_data["to"]), help_mess, mess_data['type'], unicode(_from), {}, profile=profile) - + self._feedBack(help_mess, mess_data, profile)