Hexchat python script to alert on message that matches pattern reddit / irc ---------------------------------------------------------------------- gigapants · 2023-11-10 01:22 Hello, I'm looking for some help on how to setup a python script in hexchat to generate desktop notifications in Ubuntu if a message in a channel matches a pattern. I got chatgpt to write up an example, it sort of looks like it works but loading it up hexchat doesn't have a mainloop attribute and I'm unsure how to get this working. import hexchat import re import subprocess import time # Define the pattern to match PATTERN = "your_pattern_here" # Command to display desktop notification NOTIFY_COMMAND = ["notify-send", "HexChat Notification"] def message_handler(word, word_eol, userdata): line = word[1] # Check if the line matches the pattern if re.search(PATTERN, line): # Send a desktop notification subprocess.run(NOTIFY_COMMAND + [line]) return hexchat.EAT_NONE # Hook the message handler to HexChat events hexchat.hook_print("Channel Message", message_handler) hexchat.hook_print("Your Message", message_handler) # Run the HexChat main loop hexchat.mainloop() ---------------------------------------------------------------------- verylittlegravitaas · 2023-11-10 04:05 I don't have an answer for you, but as a career programmer: _gulp_ ---------------------------------------------------------------------- verylittlegravitaas · 2023-11-10 04:12 Just to not be completely useless.. I don't see the `mainloop` method in the Hexchat Python Interface docs. I'm guessing it's not necessary if this [script is loaded when you start Hexchat](https://hexchat.read thedocs.io/en/latest/script_python.html#autoloading-modules). The `hook_print` callbacks [should be triggered](https://hexchat.readthedo cs.io/en/latest/script_python.html#hexchat.hook_print). Disclaimer: I've never used Hexchat. ---------------------------------------------------------------------- ipsirc · 2023-11-10 07:02 preferences >>> alert >>> highlighted messages >>> Extra words to highlight ---------------------------------------------------------------------- osxdude · 2023-11-10 14:05 It's been years since I've used Hexchat. It's been years since I've used IRC. And I knew this feature existed ---------------------------------------------------------------------- gigapants · 2023-11-10 20:00 This creates notifications in the dock but they aren't push notifications which is what I'm looking for. Thanks though ---------------------------------------------------------------------- ipsirc · 2023-11-11 16:54 it's also just a matter of setting where to send the notification.