# HG changeset patch # User Goffi # Date 1426771808 -3600 # Node ID 876c9fbd0b3ddd25286035f90cd5efbacc5be838 # Parent 53c7678c27a6ad888e9693852e29f79516b7754b plugin text command, XEP-0045, XEP-0048, XEP-0249: removed feedBackWrongContext which is no more usefull with new _contextValid method diff -r 53c7678c27a6 -r 876c9fbd0b3d src/plugins/plugin_misc_text_commands.py --- a/src/plugins/plugin_misc_text_commands.py Thu Mar 19 14:29:03 2015 +0100 +++ b/src/plugins/plugin_misc_text_commands.py Thu Mar 19 14:30:08 2015 +0100 @@ -270,19 +270,6 @@ self.host.bridge.newMessage(unicode(mess_data["to"]), message, C.MESS_TYPE_INFO, unicode(_from), {}, profile=profile) - def feedBackWrongContext(self, command, types, mess_data, profile): - """Give a generic message to the user when a command has been used in a wrong context. - - @param command (string): the command name (without the slash) - @param types (string, list): the message types to which the command applies. - @param mess_data (dict): original message data - @param profile: %(doc_profile)s - """ - if not isinstance(types, str): - types = _(' or ').join(types) - feedback = _("/%(command)s command only applies on %(type)s messages. ") % {'command': command, 'type': types} - self.host.plugins[C.TEXT_CMDS].feedBack(feedback + self.HELP_SUGGESTION, mess_data, profile) - def cmd_whois(self, mess_data, profile): """show information on entity""" log.debug("Catched whois command") diff -r 53c7678c27a6 -r 876c9fbd0b3d src/plugins/plugin_xep_0045.py --- a/src/plugins/plugin_xep_0045.py Thu Mar 19 14:29:03 2015 +0100 +++ b/src/plugins/plugin_xep_0045.py Thu Mar 19 14:30:08 2015 +0100 @@ -448,28 +448,24 @@ # Text commands # def cmd_nick(self, mess_data, profile): - """change nickname""" - log.debug("Catched nick command") + """change nickname - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('nick', 'groupchat', mess_data, profile) - return False - + @command (group): new_nick + - new_nick: new nick to use + """ nick = mess_data["unparsed"].strip() - room = mess_data["to"] - - self.nick(room, nick, profile) + if nick: + room = mess_data["to"] + self.nick(room, nick, profile) return False def cmd_join(self, mess_data, profile): - """join a new room (on the same service if full jid is not specified)""" - log.debug("Catched join command") + """join a new room - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('join', 'groupchat', mess_data, profile) - return False - + @command (group): JID + - JID: room to join (on the same service if full jid is not specified) + """ if mess_data["unparsed"].strip(): room_jid = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) nick = (self.getRoomNick(room_jid, profile) or @@ -479,13 +475,11 @@ return False def cmd_leave(self, mess_data, profile): - """quit a room""" - log.debug("Catched leave command") + """quit a room - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('leave', 'groupchat', mess_data, profile) - return False - + @command (group): [ROOM_JID] + - ROOM_JID: jid of the room to live (current room if not specified) + """ if mess_data["unparsed"].strip(): room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) else: @@ -496,21 +490,19 @@ return False def cmd_part(self, mess_data, profile): - """just a synonym of /leave""" + """just a synonym of /leave + + @command (group): [ROOM_JID] + - ROOM_JID: jid of the room to live (current room if not specified) + """ return self.cmd_leave(mess_data, profile) def cmd_kick(self, mess_data, profile): """kick a room member - @command (group): (nick) - - nick: the nick of the person to kick + @command (group): ROOM_NICK + - ROOM_NICK: the nick of the person to kick """ - log.debug("Catched kick command") - - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('kick', 'groupchat', mess_data, profile) - return False - options = mess_data["unparsed"].strip().split() try: nick = options[0] @@ -537,12 +529,6 @@ - JID: the JID of the entity to ban - reason: the reason why this entity is being banned """ - log.debug("Catched ban command") - - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('ban', 'groupchat', mess_data, profile) - return False - options = mess_data["unparsed"].strip().split() try: jid_s = options[0] @@ -575,12 +561,6 @@ - none: reset entity privileges - outcast: ban entity """ - log.debug("Catched affiliate command") - - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('affiliate', 'groupchat', mess_data, profile) - return False - options = mess_data["unparsed"].strip().split() try: jid_s = options[0] @@ -607,13 +587,11 @@ return d def cmd_title(self, mess_data, profile): - """change room's subject""" - log.debug("Catched title command") + """change room's subject - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('title', 'groupchat', mess_data, profile) - return False - + @command (group): title + - title: new room subject + """ subject = mess_data["unparsed"].strip() if subject: @@ -623,7 +601,11 @@ return False def cmd_topic(self, mess_data, profile): - """just a synonym of /title""" + """just a synonym of /title + + @command (group): title + - title: new room subject + """ return self.cmd_title(mess_data, profile) def _whois(self, whois_msg, mess_data, target_jid, profile): diff -r 53c7678c27a6 -r 876c9fbd0b3d src/plugins/plugin_xep_0048.py --- a/src/plugins/plugin_xep_0048.py Thu Mar 19 14:29:03 2015 +0100 +++ b/src/plugins/plugin_xep_0048.py Thu Mar 19 14:30:08 2015 +0100 @@ -423,14 +423,9 @@ @command (group): [autojoin | remove] - autojoin: join room automatically on connection """ - log.debug("Catched bookmark command") client = self.host.getClient(profile) txt_cmd = self.host.plugins[C.TEXT_CMDS] - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('bookmark', 'groupchat', mess_data, profile) - return False - options = mess_data["unparsed"].strip().split() if options and options[0] not in ('autojoin', 'remove'): txt_cmd.feedBack(_("Bad arguments"), mess_data, profile) diff -r 53c7678c27a6 -r 876c9fbd0b3d src/plugins/plugin_xep_0249.py --- a/src/plugins/plugin_xep_0249.py Thu Mar 19 14:29:03 2015 +0100 +++ b/src/plugins/plugin_xep_0249.py Thu Mar 19 14:30:08 2015 +0100 @@ -171,12 +171,6 @@ @command (group): (JID) - JID: the JID of the person to invite """ - log.debug("Catched invite command") - - if mess_data['type'] != "groupchat": - self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('invite', 'groupchat', mess_data, profile) - return False - jid_s = mess_data["unparsed"].strip() try: assert(jid_s)