import hexchat import time __module_name__ = "AutoNickServ" __module_version__ = "1.12" __module_description__ = "Smart notice-triggered auto-identifier with zero help menu interference" # ============================================================================== # CONFIGURATION: Map your exact HexChat Network names to your passwords. # Case-sensitive. Matches what shows in your HexChat Network List. # ============================================================================== PASSWORDS = { # "NetworkName": "password", # "NetworkName": "password", # "NetworkName": "password", } last_authenticated = {} def notice_callback(word, word_eol, userdata): if len(word) < 1 or len(word_eol) < 4: return hexchat.EAT_NONE sender = str(word[0]).lstrip(":").split("!", 1)[0].lower() message = str(word_eol[3]).lstrip(":").lower() network = hexchat.get_info("network") # Cooldown to prevent any auth loops (30 seconds per network) now = time.time() if network in last_authenticated and (now - last_authenticated[network] < 30): return hexchat.EAT_NONE if network in PASSWORDS: password = PASSWORDS[network] # STRICT AUTH PROMPTS ONLY: # These are the exact phrases services send when you are unrecognized/unidentified. # Help menus, command lists, and info text will not match these, so they flow through untouched. is_auth_prompt = any(phrase in message for phrase in [ "please identify using", "to identify yourself, type", "identify via", "status: unrecognized", "you are not identified" ]) if is_auth_prompt: if "nickop" in sender and network.lower() == "austnet": hexchat.command(f"QUOTE PRIVMSG NickOP :IDENTIFY {password}") hexchat.command(f'echo \x0304[AutoNickServ]\x03 Auto-identified via NickOP prompt on {network}') last_authenticated[network] = now elif "nickserv" in sender: hexchat.command(f"ns identify {password}") hexchat.command(f'echo \x0304[AutoNickServ]\x03 Auto-identified via NickServ prompt on {network}') last_authenticated[network] = now # CRITICAL: Always return EAT_NONE so the notice (including help menus) # is never swallowed or blocked from displaying in your window! return hexchat.EAT_NONE def manual_identify_command(word, word_eol, userdata): network = hexchat.get_info("network") if network in PASSWORDS: password = PASSWORDS[network] if network.lower() == "austnet": hexchat.command(f"QUOTE PRIVMSG NickOP :IDENTIFY {password}") else: hexchat.command(f"ns identify {password}") hexchat.command(f'echo \x0303[AutoNickServ]\x03 Manually triggered identification for: {network}') else: print(f'\x0304[AutoNickServ]\x03 No password found for network: {network}') return hexchat.EAT_ALL # Hook notices to catch live service prompts, returning EAT_NONE to let everything else through hexchat.hook_server("NOTICE", notice_callback, priority=hexchat.PRI_LOW) hexchat.hook_command("nsident", manual_identify_command, help="Manually sends saved password") print(f"\x0303[{__module_name__} v{__module_version__} loaded]\x03") marc@destiny:~$