From 69c6b38894b8099a641ca431e47af6805eeab6b2 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 17 Oct 2011 21:29:39 +0200 Subject: remove /visitor /participant /moderator and replace them with /role --- src/tabs.py | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'src/tabs.py') 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 \nIgnore: Ignore a specified nickname."), None) self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) self.commands['kick'] = (self.command_kick, _("Usage: /kick [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 [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 [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 [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 [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 \nTopic: Change the subject of the room"), self.completion_topic) self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . 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 [reason] """ - self._command_change_role('none', 'kick', arg) - - def command_visitor(self, arg): - """ - /visitor [reason] - """ - self._command_change_role('visitor', 'visitor', arg) - - def command_participant(self, arg): - """ - /participant [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 [reason] + /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): """ -- cgit v1.2.3 From b29f11ce19188f277d8b94a640fe54c19f2b7972 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 17 Oct 2011 21:30:36 +0200 Subject: /affiliation command (without the 'outcast' affiliation ATM) --- src/tabs.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index ad4b9ca9..2b1b586a 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -405,6 +405,7 @@ class MucTab(ChatTab): self.commands['unignore'] = (self.command_unignore, _("Usage: /unignore \nUnignore: Remove the specified nickname from the ignore list."), self.completion_unignore) self.commands['kick'] = (self.command_kick, _("Usage: /kick [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason."), None) self.commands['role'] = (self.command_role, _("Usage: /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['affiliation'] = (self.command_affiliation, _("Usage: /affiliation [reason]\nAffiliation: Set the affiliation of an user. Affiliations can be: outcast, none, member, admin, owner. You also can give an optional reason."), None) self.commands['topic'] = (self.command_topic, _("Usage: /topic \nTopic: Change the subject of the room"), self.completion_topic) self.commands['query'] = (self.command_query, _('Usage: /query [message]\nQuery: Open a private conversation with . 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) @@ -651,22 +652,27 @@ class MucTab(ChatTab): if res['type'] == 'error': self.core.room_error(res, self.get_name()) - def _command_change_role(self, role, command, arg): + def command_affiliation(self, arg): """ - Changes the role of the nick in args[0] + /affiliation [reason] + Changes the affiliation of an user + roles can be: none, visitor, participant, moderator """ args = common.shell_split(arg) - if len(args) < 1: - self.core.command_help(command) + if len(args) < 2: + self.core.command_help('role') return - nick = args[0] - if len(args) >= 2: - reason = ' '.join(args[1:]) + nick, affiliation = args[0],args[1] + if len(args) > 2: + reason = ' '.join(args[2:]) else: reason = '' - if not self.get_room().joined: + if not self.get_room().joined or \ + not affiliation in ('none', 'member', 'admin', 'owner'): +# replace this ↑ with this ↓ when the ban list support is done +# not affiliation in ('outcast', 'none', 'member', 'admin', 'owner'): return - res = muc.set_user_role(self.core.xmpp, self.get_name(), nick, reason, role) + res = muc.set_user_affiliation(self.core.xmpp, self.get_name(), nick, reason, affiliation) if res['type'] == 'error': self.core.room_error(res, self.get_name()) -- cgit v1.2.3