32
32
weechat .config_set_plugin (key , val )
33
33
34
34
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
36
45
sound = 'Pong' if weechat .config_get_plugin ('sound' ) == 'on' else lambda :_
37
46
sound_on_other_message = 'Pong' if weechat .config_get_plugin ('sound_on_other_message' ) == 'on' else lambda :_
47
+
38
48
channel = weechat .buffer_get_string (buffer , 'localvar_channel' )
49
+
50
+ #Send notification
39
51
if weechat .config_get_plugin ('show_highlights' ) == 'on' and int (highlight ):
40
52
if weechat .config_get_plugin ('show_message_text' ) == 'on' :
41
53
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):
48
60
Notifier .notify ('From %s' % prefix , title = 'Private Message' , sound = sound )
49
61
elif weechat .config_get_plugin ('show_other_message' ) == 'on' :
50
62
Notifier .notify (message , title = 'By %s in %s' % (prefix , channel ), sound = sound_on_other_message )
63
+
51
64
return weechat .WEECHAT_RC_OK
52
65
53
66
weechat .hook_print ('' , 'irc_privmsg' , '' , 1 , 'notify' , '' )
0 commit comments