diff --git a/src/plugins/plugin_misc_text_commands.py b/src/plugins/plugin_misc_text_commands.py index 88957888..97913aa2 100755 --- a/src/plugins/plugin_misc_text_commands.py +++ b/src/plugins/plugin_misc_text_commands.py @@ -77,6 +77,15 @@ class TextCommands(): 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 @@ class TextCommands(): 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 @@ class TextCommands(): 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)