Skip to content

Instantly share code, notes, and snippets.

@14mRh4X0r
Last active December 16, 2015 05:58
Show Gist options
  • Save 14mRh4X0r/5387808 to your computer and use it in GitHub Desktop.
Save 14mRh4X0r/5387808 to your computer and use it in GitHub Desktop.
Python module for XChat/HexChat to filter messages to @#[channel] into their own tab/window
import hexchat
__module_name__ = "Filter prefix-channel messages"
__module_version__ = "0.3.1"
__module_description__ = "Places messages to [prefix]#[channel] in their own tab"
def filter_atmsg(word, word_eol, userdata, attrs):
if len(word[2]) >= 2 and word[2][1] == '#' and word[2][0] != '#':
user = word[0]
bangind = user.find("!")
user = user[1:bangind] if bangind > 0 else user
server = hexchat.get_info("server")
ctx = hexchat.find_context(server=server, channel=word[2])
if ctx == None:
hexchat.command("query -nofocus %s" % word[2])
ctx = hexchat.find_context(server=server, channel=word[2])
ctx.emit_print("Channel Message", user, word_eol[3][1:], "",
time=attrs.time)
return hexchat.EAT_HEXCHAT
hexchat.hook_server_attrs("PRIVMSG", filter_atmsg)
# vim: set et sts=4 sw=4 tw=79:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment