diff src/plugins/plugin_xep_0045.py @ 1371:876c9fbd0b3d

plugin text command, XEP-0045, XEP-0048, XEP-0249: removed feedBackWrongContext which is no more usefull with new _contextValid method
author Goffi <goffi@goffi.org>
date Thu, 19 Mar 2015 14:30:08 +0100
parents bf3f669a6052
children 0d12d4e32664
line wrap: on
line diff
--- 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):