Commit 5da85b94 authored by Eijebong's avatar Eijebong

Add a random arg to /color

parent 3c46d497
...@@ -327,6 +327,7 @@ MultiUserChat tab commands ...@@ -327,6 +327,7 @@ MultiUserChat tab commands
Use the completion to get a list of all the available color values. Use the completion to get a list of all the available color values.
Use the special color **unset** to remove the attributed color on Use the special color **unset** to remove the attributed color on
this nick. this nick.
You can also use **random** to attribute a random color.
/clear [MUCTab version] /clear [MUCTab version]
**Usage:** ``/clear`` **Usage:** ``/clear``
......
...@@ -279,6 +279,7 @@ class MucTab(ChatTab): ...@@ -279,6 +279,7 @@ class MucTab(ChatTab):
colors = [i for i in xhtml.colors if i] colors = [i for i in xhtml.colors if i]
colors.sort() colors.sort()
colors.append('unset') colors.append('unset')
colors.append('random')
return the_input.new_completion(colors, 2, '', quotify=False) return the_input.new_completion(colors, 2, '', quotify=False)
def completion_ignore(self, the_input): def completion_ignore(self, the_input):
...@@ -466,14 +467,15 @@ class MucTab(ChatTab): ...@@ -466,14 +467,15 @@ class MucTab(ChatTab):
""" """
/color <nick> <color> /color <nick> <color>
Fix a color for a nick. Fix a color for a nick.
Use "unset" instead of a color to remove the attribution Use "unset" instead of a color to remove the attribution.
User "random" to attribute a random color.
""" """
if args is None: if args is None:
return self.core.command_help('color') return self.core.command_help('color')
nick = args[0] nick = args[0]
color = args[1].lower() color = args[1].lower()
user = self.get_user_by_name(nick) user = self.get_user_by_name(nick)
if not color in xhtml.colors and color != 'unset': if not color in xhtml.colors and color not in ('unset', 'random'):
return self.core.information(_("Unknown color: %s") % color, 'Error') return self.core.information(_("Unknown color: %s") % color, 'Error')
if user and user.nick == self.own_nick: if user and user.nick == self.own_nick:
return self.core.information(_("You cannot change the color of your" return self.core.information(_("You cannot change the color of your"
...@@ -482,6 +484,8 @@ class MucTab(ChatTab): ...@@ -482,6 +484,8 @@ class MucTab(ChatTab):
if config.remove_and_save(nick, 'muc_colors'): if config.remove_and_save(nick, 'muc_colors'):
self.core.information(_('Color for nick %s unset') % (nick)) self.core.information(_('Color for nick %s unset') % (nick))
else: else:
if color == 'random':
color = random.choice(list(xhtml.colors))
if user: if user:
user.change_color(color) user.change_color(color)
config.set_and_save(nick, color, 'muc_colors') config.set_and_save(nick, color, 'muc_colors')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment