1
1
# https://github.com/sindresorhus/weechat-notification-center
2
2
# 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
+ #
3
8
4
9
import weechat
5
10
from pync import Notifier
17
22
'show_highlights' : 'on' ,
18
23
'show_private_message' : 'on' ,
19
24
'show_message_text' : 'on' ,
20
- 'sound' : 'off' ,
25
+ 'show_other_message' : 'on' ,
26
+ 'sound' : 'on' ,
27
+ 'sound_on_other_message' : 'off'
21
28
}
22
29
23
30
for key , val in DEFAULT_OPTIONS .items ():
24
31
if not weechat .config_is_set_plugin (key ):
25
32
weechat .config_set_plugin (key , val )
26
33
27
- weechat .hook_print ('' , 'irc_privmsg' , '' , 1 , 'notify' , '' )
28
-
29
34
def notify (data , buffer , date , tags , displayed , highlight , prefix , message ):
30
35
# passing `None` or `''` still plays the default sound so we pass a lambda instead
31
36
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 ):
34
40
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 )
36
42
else :
37
43
Notifier .notify ('In %s by %s' % (channel , prefix ), title = 'Highlighted Message' , sound = sound )
38
44
elif weechat .config_get_plugin ('show_private_message' ) == 'on' and 'notify_private' in tags :
39
45
if weechat .config_get_plugin ('show_message_text' ) == 'on' :
40
46
Notifier .notify (message , title = '%s [private]' % prefix , sound = sound )
41
47
else :
42
48
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 )
43
51
return weechat .WEECHAT_RC_OK
52
+
53
+ weechat .hook_print ('' , 'irc_privmsg' , '' , 1 , 'notify' , '' )
0 commit comments