Commit 8cc920a4 authored by Sindre Sorhus's avatar Sindre Sorhus Committed by Sébastien Helleu

notification_center.py 1.5.1: fix the channels option

parent b12d9aab
......@@ -9,7 +9,7 @@ from pync import Notifier
SCRIPT_NAME = 'notification_center'
SCRIPT_AUTHOR = 'Sindre Sorhus <[email protected]>'
SCRIPT_VERSION = '1.5.0'
SCRIPT_VERSION = '1.5.1'
SCRIPT_LICENSE = 'MIT'
SCRIPT_DESC = 'Pass highlights and private messages to the macOS Notification Center'
WEECHAT_ICON = os.path.expanduser('~/.weechat/weechat.png')
......@@ -36,30 +36,33 @@ for key, val in DEFAULT_OPTIONS.items():
weechat.hook_print('', 'irc_privmsg,' + weechat.config_get_plugin('tags'), '', 1, 'notify', '')
def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
# ignore if it's yourself
# 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
# ignore messages from the current buffer
# Ignore messages from the current buffer
if weechat.config_get_plugin('ignore_current_buffer_messages') == 'on' and buffer == weechat.current_buffer():
return weechat.WEECHAT_RC_OK
# ignore messages older than the configured theshold (such as ZNC logs) if enabled
# Ignore messages older than the configured theshold (such as ZNC logs) if enabled
if weechat.config_get_plugin('ignore_old_messages') == 'on':
message_time = datetime.datetime.utcfromtimestamp(int(date))
now_time = datetime.datetime.utcnow()
# ignore if the message is greater than 5 seconds old
# Ignore if the message is greater than 5 seconds old
if (now_time - message_time).seconds > 5:
return weechat.WEECHAT_RC_OK
# passing `None` or `''` still plays the default sound so we pass a lambda instead
# Passing `None` or `''` still plays the default sound so we pass a lambda instead
sound = weechat.config_get_plugin('sound_name') if weechat.config_get_plugin('sound') == 'on' else lambda:_
activate_bundle_id = weechat.config_get_plugin('activate_bundle_id')
channel_whitelist = weechat.config_get_plugin('channels').split(',')
channel_whitelist = []
if weechat.config_get_plugin('channels') != "":
channel_whitelist = weechat.config_get_plugin('channels').split(',')
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
if channel in channel_whitelist:
if weechat.config_get_plugin('show_message_text') == 'on':
Notifier.notify(message, title='%s %s' % (prefix, channel), sound=sound, appIcon=WEECHAT_ICON, activate=activate_bundle_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment