Skip to content

Commit 4afd5e5

Browse files
author
Gianni Van Hoecke
committed
Don't show notification if sender is own nickname and format the message as a raw string
1 parent 8be9105 commit 4afd5e5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

notification_center.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,22 @@
3232
weechat.config_set_plugin(key, val)
3333

3434
def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
35-
# passing `None` or `''` still plays the default sound so we pass a lambda instead
35+
36+
#If own nickname is sender, ignore
37+
mynick = weechat.buffer_get_string(buffer,'localvar_nick')
38+
if prefix == mynick or prefix == ('@%s' % mynick):
39+
return weechat.WEECHAT_RC_OK
40+
41+
#Format message
42+
message = repr(message.encode('string-escape'))
43+
44+
#Passing `None` or `''` still plays the default sound so we pass a lambda instead
3645
sound = 'Pong' if weechat.config_get_plugin('sound') == 'on' else lambda:_
3746
sound_on_other_message = 'Pong' if weechat.config_get_plugin('sound_on_other_message') == 'on' else lambda:_
47+
3848
channel = weechat.buffer_get_string(buffer, 'localvar_channel')
49+
50+
#Send notification
3951
if weechat.config_get_plugin('show_highlights') == 'on' and int(highlight):
4052
if weechat.config_get_plugin('show_message_text') == 'on':
4153
Notifier.notify(message, title='Highlighted by %s in %s' % (prefix, channel), sound=sound)
@@ -48,6 +60,7 @@ def notify(data, buffer, date, tags, displayed, highlight, prefix, message):
4860
Notifier.notify('From %s' % prefix, title='Private Message', sound=sound)
4961
elif weechat.config_get_plugin('show_other_message') == 'on':
5062
Notifier.notify(message, title='By %s in %s' % (prefix, channel), sound=sound_on_other_message)
63+
5164
return weechat.WEECHAT_RC_OK
5265

5366
weechat.hook_print('', 'irc_privmsg', '', 1, 'notify', '')

0 commit comments

Comments
 (0)