weechat-old/python/autoload/notify.py @ 27ec64715a7b
Update subrepo
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 07 Nov 2023 10:00:59 -0500 |
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