hexchatModules

Modules for hexchat

Usage: Put the scripts into your .config/hexchat folder for automatic loading on startup.

VIP-join

VIP-Join

What?
A python module, that performs highlighting if certain users join a channel. Save as vip-join.py
Usage
The script will create a file "vip-join.conf", where all usernames are saved, that you want to be highlighted. Use "/vip-add nick" to add "nick" to the list, "/vip-list" to display all saved usernames and "/vip-remove nick" to remove "nick" from the list.
Script
__module_name__ = "VIP Notification"
__module_version__ = "1.0"
__module_description__ = "highlights certain vip-nicks"

import xchat
import re
import os

CONFFILE = os.environ['HOME'] + "/.xchat2/vip-join.conf"
nicks=[]

xchat.prnt("%s,version %s loaded" %(__module_name__,__module_version__))

def read_list():
    try:
        conf = open(CONFFILE,'r')
    except:
        xchat.prnt(CONFFILE+ " currently does not exist, creating")
        return None
    lines = conf.readlines()
    for line in lines:
        nicks.append(line.strip())
    conf.close()

def save_list():
    conf = open(CONFFILE,"w")
    for user in nicks:
        conf.write(user + "\n")
    conf.close()

def join_cb(words, words_eol, userdata):
    if words[1] == "JOIN":
        for user in nicks:
            if re.match(".*"+user+".*", words[0], re.IGNORECASE ) != None:
                xchat.emit_print("Channel Msg Hilight","","%s joined %s" %(user,words[2]))

    return xchat.EAT_NONE

def add_vip(word,word_eol,userdata):
    if len(word) == 1:
        return list_vip(word,word_eol,userdata)
    user = word[1]
    if user not in nicks:
        nicks.append(user)
        xchat.prnt("%s will be highlighted" %user)
    else:
        xchat.prnt("%s is already being highlighted" %user)
    save_list()
    return xchat.EAT_XCHAT

def list_vip(word,word_eol,userdata):
    xchat.prnt("\nCurrently highlighted VIPs:")
    for user in nicks:
        xchat.prnt("%s" %user)
    return xchat.EAT_XCHAT

def remove_vip(word,word_eol,userdata):
    user = word[1]
    if user in nicks:
        nicks.remove(user)
        xchat.prnt("%s has been removed from VIP list" %user)
    else:
        xchat.prnt("%s not in VIP list" %user)
    save_list()
    return xchat.EAT_XCHAT

read_list()
xchat.hook_command("vip-add",add_vip)
xchat.hook_command("vip-list",list_vip)
xchat.hook_command("vip-remove",remove_vip)


hook = xchat.hook_server("JOIN", join_cb, None, priority=xchat.PRI_NORM)