Colored Nicks based on Usermode

By Firstmate on Mar 19, 2011

The script just let's you have colored nicks.

The customizable part of this script is on this line (a comment is there):

#[no mode, color, +, color, %, color, @, color, &, color, ~, color]
colors = [95, 8, 43, 9, 37, 10, 64, 11, 38, 12, 126, 13]

Each number indicates the mode in question (equivalent to $asc(mode) for the mIRC folks), followed by the color code to be used.

I have not really configured it to allow a 'default' color per say, but you're free to request/do so.

You're free to copy, edit, rip, or do whatever you want with the script.

Enjoy!

__module_name__ = "Color nick"
__module_version__ = "0.1"
__module_description__ = "Colors nicks in channel messages based on usermode"

import xchat
import re

colorRe = re.compile(r"(||[0-9]{1,2}(,[0-9]{1,2}|))")
#[no mode, color, +, color, %, color, @, color, &, color, ~, color]
colors = [95, 8, 43, 9, 37, 10, 64, 11, 38, 12, 126, 13]

def check_message(word, word_eol, userdata):
    nick_with_color = word[0]
    line = word[1]
    nick = colorRe.sub("",nick_with_color)
    if nick != nick_with_color:
        return xchat.EAT_NONE

    users = xchat.get_list("users")
    prefix = get_prefix(users,nick)
    if prefix == '':
        prefix = "_"
    color = colors
    if prefix == "_":
        prefix = ''
    nick = "%c%d%s%s%c" % ('',color,prefix,nick,'')

    xchat.emit_print("Channel Message", nick, line)
    return xchat.EAT_ALL

def get_prefix(users,nick):
    for i in users:
        if (i.nick == nick):
            return i.prefix
    return "+"

xchat.hook_print("Channel Message", check_message)

print "Loaded "+__module_name__+" v"+__module_version__

Comments

Sign in to comment.
Firstmate   -  Mar 19, 2011

I'll keep that in mind. Thanks! I was aware of the method, just didn't realize the other method would be gone.

 Respond  
sunslayer   -  Mar 19, 2011

%-formatting is planning to be deprecated in future releases over the newer str.format() method

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.