summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-10-17 21:29:39 +0200
committermathieui <mathieui@mathieui.net>2011-10-17 21:29:39 +0200
commit69c6b38894b8099a641ca431e47af6805eeab6b2 (patch)
treeead08628636afadbdbdacf3ddd5f548d6371cb9f /src
parent7d392c609348c28f9fae108955d79f150d4f47d5 (diff)
downloadpoezio-69c6b38894b8099a641ca431e47af6805eeab6b2.tar.gz
poezio-69c6b38894b8099a641ca431e47af6805eeab6b2.tar.bz2
poezio-69c6b38894b8099a641ca431e47af6805eeab6b2.tar.xz
poezio-69c6b38894b8099a641ca431e47af6805eeab6b2.zip
remove /visitor /participant /moderator and replace them with /role
Diffstat (limited to 'src')
-rw-r--r--src/multiuserchat.py2
-rw-r--r--src/tabs.py43
2 files changed, 25 insertions, 20 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 67fa32e6..b00b4599 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -70,7 +70,7 @@ def leave_groupchat(xmpp, jid, own_nick, msg):
def set_user_role(xmpp, jid, nick, reason, role):
"""
(try to) Set the role of a MUC user
- (role =) 'none': eject user)
+ (role = 'none': eject user)
"""
iq = xmpp.makeIqSet()
query = ET.Element('{%s}query' % NS_MUC_ADMIN)
diff --git a/src/tabs.py b/src/tabs.py
index 0ab6e1bb..ad4b9ca9 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -404,9 +404,7 @@ class MucTab(ChatTab):
self.commands['ignore'] = (self.command_ignore, _("Usage: /ignore <nickname> \nIgnore: Ignore a specified nickname."), None)
self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore <nickname>\nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore)
self.commands['kick'] = (self.command_kick, _("Usage: /kick <nick> [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), None)
- self.commands['moderator'] = (self.command_moderator, _("Usage: /moderator <nick> [reason]\nModerator: Op the user with the specified nickname. You also can give an optional reason."), None)
- self.commands['visitor'] = (self.command_visitor, _("Usage: /visitor <nick> [reason]\nVisitor: Mute the user with the specified nickname. You also can give an optional reason."), None)
- self.commands['participant'] = (self.command_participant, _("Usage: /participant <nick> [reason]\nParticipant: Voice the user with the specified nickname. You also can give an optional reason."), None)
+ self.commands['role'] = (self.command_role, _("Usage: /role <nick> <role> [reason]\nRole: Set the role of an user. Roles can be: none, visitor, participant, moderator. You also can give an optional reason."), None)
self.commands['topic'] = (self.command_topic, _("Usage: /topic <subject>\nTopic: Change the subject of the room"), self.completion_topic)
self.commands['query'] = (self.command_query, _('Usage: /query <nick> [message]\nQuery: Open a private conversation with <nick>. This nick has to be present in the room you\'re currently in. If you specified a message after the nickname, it will immediately be sent to this user'), None)
self.commands['part'] = (self.command_part, _("Usage: /part [message]\nPart: disconnect from a room. You can specify an optional message."), None)
@@ -626,25 +624,32 @@ class MucTab(ChatTab):
"""
/kick <nick> [reason]
"""
- self._command_change_role('none', 'kick', arg)
-
- def command_visitor(self, arg):
- """
- /visitor <nick> [reason]
- """
- self._command_change_role('visitor', 'visitor', arg)
-
- def command_participant(self, arg):
- """
- /participant <nick> [reason]
- """
- self._command_change_role('participant', 'participant', arg)
+ args = common.shell_split(arg)
+ if not len(args):
+ self.core.command_help('kick')
+ self._command_change_role('kick '+arg)
- def command_moderator(self, arg):
+ def command_role(self, arg):
"""
- /moderator <nick> [reason]
+ /role <nick> <role> [reason]
+ Changes the role of an user
+ roles can be: none, visitor, participant, moderator
"""
- self._command_change_role('moderator', 'moderator', arg)
+ args = common.shell_split(arg)
+ if len(args) < 2:
+ self.core.command_help('role')
+ return
+ nick, role = args[0],args[1]
+ if len(args) > 2:
+ reason = ' '.join(args[2:])
+ else:
+ reason = ''
+ if not self.get_room().joined or \
+ not role in ('none', 'visitor', 'participant', 'moderator'):
+ return
+ res = muc.set_user_role(self.core.xmpp, self.get_name(), nick, reason, role)
+ if res['type'] == 'error':
+ self.core.room_error(res, self.get_name())
def _command_change_role(self, role, command, arg):
"""