summaryrefslogtreecommitdiff
path: root/src/tabs
diff options
context:
space:
mode:
authorCélestin Matte <celestin.matte@gmail.com>2014-12-22 18:47:25 +0100
committerCélestin Matte <celestin.matte@gmail.com>2014-12-24 00:27:38 +0100
commitf7e7836f977555bd589b693947b8e4d06c1134b1 (patch)
treecdc30b9ce632f1d69b991f5c54b4c91cdc10e626 /src/tabs
parent3c195dd9ccef1adbb59ad8db7fcc7086fd01b667 (diff)
downloadpoezio-f7e7836f977555bd589b693947b8e4d06c1134b1.tar.gz
poezio-f7e7836f977555bd589b693947b8e4d06c1134b1.tar.bz2
poezio-f7e7836f977555bd589b693947b8e4d06c1134b1.tar.xz
poezio-f7e7836f977555bd589b693947b8e4d06c1134b1.zip
Add a /color command to fix color for a nick
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/muctab.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index 72478bd4..160c4b0e 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -158,6 +158,11 @@ class MucTab(ChatTab):
' for a non-deterministic result.'),
shortdesc=_('Change the nicks colors.'),
completion=self.completion_recolor)
+ self.register_command('color', self.command_color,
+ usage=_('<nick> <color>'),
+ desc=_('Fix a color for a nick.'),
+ shortdesc=_('Fix a color for a nick.'),
+ completion=self.completion_color)
self.register_command('cycle', self.command_cycle,
usage=_('[message]'),
desc=_('Leave the current room and rejoin it immediately.'),
@@ -261,6 +266,19 @@ class MucTab(ChatTab):
return the_input.new_completion(['random'], 1, '', quotify=False)
return True
+ def completion_color(self, the_input):
+ """Completion for /color"""
+ n = the_input.get_argument_position(quoted=True)
+ if n == 1:
+ userlist = [user.nick for user in self.users]
+ if self.own_nick in userlist:
+ userlist.remove(self.own_nick)
+ return the_input.new_completion(userlist, 1, '', quotify=True)
+ elif n == 2:
+ colors = [i for i in xhtml.colors if i]
+ colors.sort()
+ return the_input.new_completion(colors, 2, '', quotify=False)
+
def completion_ignore(self, the_input):
"""Completion for /ignore"""
userlist = [user.nick for user in self.users]
@@ -432,6 +450,31 @@ class MucTab(ChatTab):
self.text_win.refresh()
self.input.refresh()
+ @command_args_parser.quoted(2, 2, [''])
+ def command_color(self, args):
+ """
+ /color <nick> <color>
+ Fix a color for a nick.
+ """
+ if args is None:
+ return self.core.command_help('color')
+ nick = args[0]
+ color = args[1].lower()
+ user = self.get_user_by_name(nick)
+ if not user:
+ return self.core.information(_("Unknown user: %s") % nick)
+ if not color in xhtml.colors:
+ return self.core.information(_("Unknown color: %s") % color, 'Error')
+ if user.nick == self.own_nick:
+ return self.core.information(_("You cannot change the color of your"
+ " own nick.", 'Error'))
+ colors = list(get_theme().LIST_COLOR_NICKNAMES)
+ user.color = (xhtml.colors[color], -1)
+ self.text_win.rebuild_everything(self._text_buffer)
+ self.user_win.refresh(self.users)
+ self.text_win.refresh()
+ self.input.refresh()
+
@command_args_parser.quoted(1)
def command_version(self, args):
"""