weechat/python/autoload/notify.py @ 3ee7f5f0db6b

Ffucking scrreens
author Steve Losh <steve@stevelosh.com>
date Sun, 16 Dec 2018 15:23:34 -0500
parents a1d399ef7d54
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