diff --git a/src/plugins/plugin_misc_text_commands.py b/src/plugins/plugin_misc_text_commands.py index 995886e7..88957888 100755 --- a/src/plugins/plugin_misc_text_commands.py +++ b/src/plugins/plugin_misc_text_commands.py @@ -34,6 +34,9 @@ PLUGIN_INFO = { } class TextCommands(): + #FIXME: doc strings for commands have to be translatable + # plugins need a dynamic translation system (translation + # should be downloadable independently) def __init__(self, host): info(_("Text commands initialization")) @@ -75,6 +78,7 @@ class TextCommands(): return jid.JID(u"%s@%s" % (arg, service_jid)) def cmd_nick(self, mess_data, profile): + """change nickname""" debug("Catched nick command") if mess_data['type'] != "groupchat": @@ -91,6 +95,7 @@ class TextCommands(): return False def cmd_join(self, mess_data, profile): + """join a new room (on the same service if full jid is not specified)""" debug("Catched join command") if mess_data['type'] != "groupchat": @@ -107,6 +112,7 @@ class TextCommands(): return False def cmd_leave(self, mess_data, profile): + """quit a room""" debug("Catched leave command") if mess_data['type'] != "groupchat": @@ -128,6 +134,7 @@ class TextCommands(): return self.cmd_leave(mess_data, profile) def cmd_title(self, mess_data, profile): + """Change room's subject""" debug("Catched title command") if mess_data['type'] != "groupchat": @@ -143,3 +150,29 @@ class TextCommands(): return False + def cmd_help(self, mess_data, profile): + """show help on available commands""" + commands=filter(lambda method: method.startswith('cmd_'), dir(self)) + longuest = max([len(command) for command in commands]) + help_cmds = [] + + for command in commands: + method = getattr(self, command) + try: + help_str = method.__doc__.split('\n')[0] + except AttributeError: + help_str = '' + 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) + + +