# HG changeset patch # User Goffi # Date 1350819435 -7200 # Node ID 24c0d51449e7d053fdc36be39e6f5056d0ffa344 # Parent 3446ce33247d4016fee862b1fe4f2ba4a720563a plugin text commands: added _feedback method to send an answer to user diff -r 3446ce33247d -r 24c0d51449e7 src/plugins/plugin_misc_text_commands.py --- 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)