Skip to content
Snippets Groups Projects
Commit 07cd259b authored by Dicson's avatar Dicson
Browse files

Add 'role' and 'affiliate' command to command system.

parent 8d5ddb2d
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,7 @@ class ChatCommandProcessor(CommandProcessor):
except CommandError, error:
self.echo_error("%s: %s" % (error.name, error.message))
except Exception:
self.echo_error("Error during command execution!")
self.echo_error(_("Error during command execution!"))
print_exc()
else:
self.command_succeeded = True
......
......@@ -352,6 +352,30 @@ class StandardGroupChatCommands(CommandContainer):
raise CommandError(_("Nickname not found"))
self.connection.gc_set_role(self.room_jid, who, 'none', reason or str())
@command(raw=True)
@doc(_("""Set occupant role in group chat.
Role can be given as one of the following values:
moderator, participant, visitor, none"""))
def role(self, who, role):
if role not in ('moderator', 'participant', 'visitor', 'none'):
raise CommandError(_("Invalid role given"))
if not who in gajim.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
self.connection.gc_set_role(self.room_jid, who, role)
@command(raw=True)
@doc(_("""Set occupant affiliation in group chat.
Affiliation can be given as one of the following values:
owner, admin, member, outcast, none"""))
def affiliate(self, who, affiliation):
if affiliation not in ('owner', 'admin', 'member', 'outcast', 'none'):
raise CommandError(_("Invalid affiliation given"))
if not who in gajim.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, who)
self.connection.gc_set_affiliation(self.room_jid, contact.jid,
affiliation)
@command
@doc(_("Display names of all group chat occupants"))
def names(self, verbose=False):
......
......@@ -162,7 +162,7 @@ def adapt_arguments(command, arguments, args, opts):
try:
stopper, (start, end) = args[spec_len - 2]
except IndexError:
raise CommandError("Missing arguments", command)
raise CommandError(_("Missing arguments"), command)
# The essential point of the whole play. After
# boundaries are being determined (supposingly correct)
......@@ -172,7 +172,7 @@ def adapt_arguments(command, arguments, args, opts):
raw = raw.strip() or None
if not raw and not command.empty:
raise CommandError("Missing arguments", command)
raise CommandError(_("Missing arguments"), command)
# Discard residual arguments and all of the options as
# raw command does not support options and if an option
......@@ -192,7 +192,7 @@ def adapt_arguments(command, arguments, args, opts):
if command.empty:
args.append((None, (0, 0)))
else:
raise CommandError("Missing arguments", command)
raise CommandError(_("Missing arguments"), command)
# The first stage of transforming options we have got to a format
# that can be used to associate them with declared keyword
......@@ -259,7 +259,7 @@ def adapt_arguments(command, arguments, args, opts):
for arg, (spec_key, spec_value) in zip(overlapped, spec_kwargs):
opts.append((spec_key, arg))
else:
raise CommandError("Excessive arguments", command)
raise CommandError(_("Excessive arguments"), command)
# Detect every switch and ensure it will not receive any arguments.
# Normally this does not happen unless overlapping is enabled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment