From 2afeba3c233b156daecf537eb0bb16aa6679a9e6 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Mon, 2 Nov 2015 02:41:32 -0500 Subject: [PATCH] add default hexchat plugins --- .config/hexchat/addons/mymsg.py | 37 ++++++++++++++++++++++++++++++++++++ .config/hexchat/addons/notify.py | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .config/hexchat/addons/mymsg.py create mode 100644 .config/hexchat/addons/notify.py diff --git a/.config/hexchat/addons/mymsg.py b/.config/hexchat/addons/mymsg.py new file mode 100644 index 0000000..70d8d4a --- /dev/null +++ b/.config/hexchat/addons/mymsg.py @@ -0,0 +1,37 @@ +import hexchat + +__module_name__ = 'MyMessages' +__module_author__ = 'TingPing' +__module_version__ = '3' +__module_description__ = 'Properly show your messages in ZNC' + +def privmsg_cb(word, word_eol, userdata, attrs): + # We only care about private messages, HexChat handles the rest now. + if word[2][0] == '#': + return + + mynick = hexchat.get_info('nick') + sender = word[0].split('!')[0][1:] + recipient = word[2] + network = hexchat.get_info('network') + msg = word_eol[3][1:] + + if hexchat.nickcmp(sender, mynick) == 0 and hexchat.nickcmp(recipient, mynick) != 0: + hexchat.command('query -nofocus {}'.format(recipient)) + ctx = hexchat.find_context(network, recipient) + + if '\001ACTION' in msg: + for repl in ('\001ACTION', '\001'): + msg = msg.replace(repl, '') + ctx.emit_print('Your Action', mynick, msg.strip(), time=attrs.time) + else: + ctx.emit_print('Your Message', mynick, msg, time=attrs.time) + + return hexchat.EAT_ALL + +def caps_cb(word, word_eol, userdata): + if "znc.in/self-message" in word[1]: + hexchat.command("cap req znc.in/self-message") + +hexchat.hook_server_attrs('PRIVMSG', privmsg_cb) +hexchat.hook_print('Capability List', caps_cb) diff --git a/.config/hexchat/addons/notify.py b/.config/hexchat/addons/notify.py new file mode 100644 index 0000000..fea1a35 --- /dev/null +++ b/.config/hexchat/addons/notify.py @@ -0,0 +1,41 @@ +__module_name__ = 'Notify' +__module_description__ = 'Sends a notification on highlight/notice/pm' +__module_version__ = '1.0' + +import os +import hexchat + + +def notice_callback(word, word_eol, userdata): + if hexchat.get_info("win_status") == 'active': + return + os.system( + hexchat.strip('notify-send \"Notice from %s\" \"%s\"' % + (word[0], word[1]))) + return hexchat.EAT_NONE + + +def pm_callback(word, word_eol, userdata): + if hexchat.get_info("win_status") == 'active': + return + os.system( + hexchat.strip('notify-send \"PM from %s\" \"%s\"' % + (word[0], word[1]))) + return hexchat.EAT_NONE + + +def highlight_callback(word, word_eol, userdata): + if hexchat.get_info("win_status") == 'active': + return + os.system( + hexchat.strip('notify-send \"Highlight from %s\" \"%s\"' % + (word[0], word[1]))) + return hexchat.EAT_NONE + +hexchat.hook_print("Channel Msg Hilight", highlight_callback) +hexchat.hook_print("Channel Action Hilight", highlight_callback) +hexchat.hook_print("Notice", notice_callback) +hexchat.hook_print("Private Action", pm_callback) +hexchat.hook_print("Private Message", pm_callback) +hexchat.hook_print("Private Action to Dialog", pm_callback) +hexchat.hook_print("Private Message to Dialog", pm_callback)