Skip to content

Commit 75b5d98

Browse files
author
Gianni Van Hoecke
committed
Option to show all messages + updated titles to be more clear
1 parent 6727067 commit 75b5d98

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

notification_center.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# https://github.com/sindresorhus/weechat-notification-center
22
# Requires `pip install pync`
3+
#
4+
# Updated by Gianni Van Hoecke:
5+
# - Option to show all messages
6+
# - Updated titles to be more clear
7+
#
38

49
import weechat
510
from pync import Notifier
@@ -17,27 +22,32 @@
1722
'show_highlights': 'on',
1823
'show_private_message': 'on',
1924
'show_message_text': 'on',
20-
'sound': 'off',
25+
'show_other_message': 'on',
26+
'sound': 'on',
27+
'sound_on_other_message': 'off'
2128
}
2229

2330
for key, val in DEFAULT_OPTIONS.items():
2431
if not weechat.config_is_set_plugin(key):
2532
weechat.config_set_plugin(key, val)
2633

27-
weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '')
28-
2934
def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
3035
# passing `None` or `''` still plays the default sound so we pass a lambda instead
3136
sound = 'Pong' if weechat.config_get_plugin('sound') == 'on' else lambda:_
32-
if weechat.config_get_plugin('show_highlights') == 'on' and highlight == '1':
33-
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
37+
sound_on_other_message = 'Pong' if weechat.config_get_plugin('sound_on_other_message') == 'on' else lambda:_
38+
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
39+
if weechat.config_get_plugin('show_highlights') == 'on' and int(highlight):
3440
if weechat.config_get_plugin('show_message_text') == 'on':
35-
Notifier.notify(message, title='%s %s' % (prefix, channel), sound=sound)
41+
Notifier.notify(message, title='Highlighted by %s in %s' % (prefix, channel), sound=sound)
3642
else:
3743
Notifier.notify('In %s by %s' % (channel, prefix), title='Highlighted Message', sound=sound)
3844
elif weechat.config_get_plugin('show_private_message') == 'on' and 'notify_private' in tags:
3945
if weechat.config_get_plugin('show_message_text') == 'on':
4046
Notifier.notify(message, title='%s [private]' % prefix, sound=sound)
4147
else:
4248
Notifier.notify('From %s' % prefix, title='Private Message', sound=sound)
49+
elif weechat.config_get_plugin('show_other_message') == 'on':
50+
Notifier.notify(message, title='By %s in %s' % (prefix, channel), sound=sound_on_other_message)
4351
return weechat.WEECHAT_RC_OK
52+
53+
weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '')

0 commit comments

Comments
 (0)