Added /status, /away, /online commands. Fixed command error reporting
This commit is contained in:
parent
11c83109f4
commit
306519f6e9
|
@ -30,6 +30,9 @@ class BaseError(Exception):
|
||||||
|
|
||||||
super(BaseError, self).__init__()
|
super(BaseError, self).__init__()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.message
|
||||||
|
|
||||||
class DefinitionError(BaseError):
|
class DefinitionError(BaseError):
|
||||||
"""
|
"""
|
||||||
Used to indicate errors occured on command definition.
|
Used to indicate errors occured on command definition.
|
||||||
|
|
|
@ -128,6 +128,35 @@ class StandardCommonCommands(CommandContainer):
|
||||||
|
|
||||||
self.echo(formatted)
|
self.echo(formatted)
|
||||||
|
|
||||||
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("""
|
||||||
|
Set current the status
|
||||||
|
|
||||||
|
Status can be given as one of the following values: online, away,
|
||||||
|
chat, xa, dnd.
|
||||||
|
"""))
|
||||||
|
def status(self, status, message):
|
||||||
|
if status not in ('online', 'away', 'chat', 'xa', 'dnd'):
|
||||||
|
raise CommandError("Invalid status given")
|
||||||
|
for connection in gajim.connections.itervalues():
|
||||||
|
connection.change_status(status, message)
|
||||||
|
|
||||||
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("Set the current status to away"))
|
||||||
|
def away(self, message):
|
||||||
|
if not message:
|
||||||
|
message = _("Away")
|
||||||
|
for connection in gajim.connections.itervalues():
|
||||||
|
connection.change_status('away', message)
|
||||||
|
|
||||||
|
@command('back', raw=True, empty=True)
|
||||||
|
@documentation(_("Set the current status to online"))
|
||||||
|
def online(self, message):
|
||||||
|
if not message:
|
||||||
|
message = _("Available")
|
||||||
|
for connection in gajim.connections.itervalues():
|
||||||
|
connection.change_status('online', message)
|
||||||
|
|
||||||
class StandardChatCommands(CommandContainer):
|
class StandardChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
This command container contains standard command which are unique to a chat.
|
This command container contains standard command which are unique to a chat.
|
||||||
|
|
Loading…
Reference in New Issue