Last active
January 22, 2020 22:17
-
-
Save sli/7500667 to your computer and use it in GitHub Desktop.
Auto ID and auto ghost addon for HexChat. Should be portable enough to work on any IRC network.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hexchat | |
from time import sleep | |
__module_name__ = 'AutoID' | |
__module_version__ = '0.1' | |
__module_description__ = 'Auto identify or ghost when nickname services requests it.' | |
def display_conf(): | |
hexchat.prnt('[AutoID] Current AutoID settings:') | |
n = hexchat.get_pluginpref('nick') or hexchat.get_prefs('irc_nick1') | |
p = hexchat.get_pluginpref('pass') | |
t = hexchat.get_pluginpref('triggernick') or 'NickServ' | |
i = hexchat.get_pluginpref('idtrigger') or '(none set)' | |
g = hexchat.get_pluginpref('ghosttrigger') or '(none set)' | |
hexchat.prnt('[AutoID] * Nick: %s' % n) | |
if p: | |
p = '*'*len(p) | |
hexchat.prnt('[AutoID] * Pass: %s' % p) | |
else: | |
hexchat.prnt('[AutoID] * Pass: (none set)') | |
hexchat.prnt('[AutoID] * Trigger Nick: %s' % t) | |
hexchat.prnt('[AutoID] * ID Trigger: %s' % i) | |
hexchat.prnt('[AutoID] * Ghost Trigger: %s' % g) | |
def autoid(word, word_eol, userdata): | |
if len(word) < 2: | |
display_conf() | |
else: | |
if word[1] == 'setnick': | |
hexchat.set_pluginpref('nick', word[2]) | |
hexchat.prnt('[AutoID] Nick set to \'%s\'' % word[2]) | |
elif word[1] == 'setpass': | |
hexchat.set_pluginpref('pass', word[2]) | |
hexchat.prnt('[AutoID] Pass set to \'%s\'' % word[2]) | |
elif word[1] == 'settriggernick': | |
hexchat.set_pluginpref('triggernick', word[2]) | |
hexchat.prnt('[AutoID] Trigger nick set to \'%s\'' % word[2]) | |
elif word[1] == 'setidtrigger': | |
hexchat.set_pluginpref('idtrigger', word_eol[2]) | |
hexchat.prnt('[AutoID] ID trigger phrase set to \'%s\'' % word_eol[2]) | |
elif word[1] == 'setghosttrigger': | |
hexchat.set_pluginpref('ghosttrigger', word_eol[2]) | |
hexchat.prnt('[AutoID] Ghost trigger phrase set to \'%s\'' % word_eol[2]) | |
elif word[1] == 'help': | |
hexchat.prnt('[AutoID] ----------') | |
hexchat.prnt('[AutoID] Using AutoID: /autoid <command> [arguments]') | |
hexchat.prnt('[AutoID] Commands:') | |
hexchat.prnt('[AutoID] * help - This help menu.') | |
hexchat.prnt('[AutoID] * setnick - Set preferred nick (defaults to HexChat setting)') | |
hexchat.prnt('[AutoID] * setpass - Set NickServ password') | |
hexchat.prnt('[AutoID] * settriggernick - Set trigger nick (default: NickServ)') | |
hexchat.prnt('[AutoID] * setidtrigger - Set auto identify trigger phrase') | |
hexchat.prnt('[AutoID] * setghosttrigger - Set auto ghost trigger phrase') | |
hexchat.prnt('[AutoID] * (none) - Displays current settings.') | |
hexchat.prnt('[AutoID] ----------') | |
else: | |
display_conf() | |
return hexchat.EAT_ALL | |
def run_autoid(word, word_eol, userdata): | |
if hexchat.get_pluginpref('pass'): | |
t = hexchat.get_pluginpref('triggernick') or 'NickServ' | |
if word[0].split('!')[0].replace(':','') == t: | |
if hexchat.get_pluginpref('idtrigger') and hexchat.get_pluginpref('idtrigger') in word_eol[3]: | |
hexchat.prnt('[AutoID] Auto identifying your nick.') | |
hexchat.command('nickserv identify %s' % hexchat.get_pluginpref('pass')) | |
elif hexchat.get_pluginpref('ghosttrigger') and hexchat.get_pluginpref('ghosttrigger') in word_eol[3]: | |
hexchat.prnt('[AutoID] Auto ghosting your nick.') | |
n = hexchat.get_pluginpref('nick') or hexchat.get_prefs('irc_nick1') | |
hexchat.command('nickserv ghost %s' % hexchat.get_pluginpref('pass')) | |
sleep(5) | |
hexchat.command('nick %s' % n) | |
return hexchat.EAT_NONE | |
def check_ghost(word, word_eol, userdata): | |
n = hexchat.get_pluginpref('nick') or hexchat.get_prefs('irc_nick1') | |
if hexchat.get_pluginpref('pass') and hexchat.get_info('nick') != n: | |
hexchat.command('nick %s' % n) | |
hexchat.hook_command('autoid', autoid) | |
hexchat.hook_server('Notice', run_autoid) | |
hexchat.hook_server('Connected', check_ghost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment