weechat-old/python/autoload/notify.py @ 05ef9c8cbeeb
More
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 03 Nov 2023 10:12:49 -0400 |
parents |
a9f1df02501f |
children |
(none) |
import weechat, subprocess
SCRIPT_NAME = 'notify'
SCRIPT_AUTHOR = 'Steve Losh <steve@stevelosh.com>'
SCRIPT_VERSION = '0.0.1'
SCRIPT_LICENSE = 'MIT'
SCRIPT_DESC = 'notify-send for weechat'
weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '')
weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '')
def _notify(text):
subprocess.call(['notify-send', text])
def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
# ignore if it's yourself
own_nick = weechat.buffer_get_string(buffer, 'localvar_nick')
if prefix == own_nick or prefix == ('@%s' % own_nick):
return weechat.WEECHAT_RC_OK
if int(highlight):
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
_notify('%s %s\n%s' % (prefix, channel, message))
elif 'notify_private' in tags:
_notify('%s [PM]\n%s' % (prefix, message))
return weechat.WEECHAT_RC_OK