-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgntp_notify.rb
61 lines (51 loc) · 1.61 KB
/
gntp_notify.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Author: Justin Anderson
# Email: [email protected]
# Homepage: https://github.com/tinifni/gntp-notify
# Version: 1.1
require 'rubygems'
require 'ruby_gntp'
def weechat_init
Weechat.register("gntp_notify",
"Justin Anderson",
"1.1",
"GPL3",
"GNTP Notify: Growl notifications using ruby_gntp.",
"",
"")
hook_notifications
@growl = GNTP.new("Weechat")
@growl.register({
:notifications => [{:name => "Private",
:enabled => true},
{:name => "Highlight",
:enabled => true}]
})
return Weechat::WEECHAT_RC_OK
end
def hook_notifications
Weechat.hook_signal("weechat_pv", "show_private", "")
Weechat.hook_signal("weechat_highlight", "show_highlight", "")
end
def unhook_notifications(data, signal, message)
Weechat.unhook(show_private)
Weechat.unhook(show_highlight)
end
def show_private(data, signal, message)
message[0..1] == '--' ? sticky = false : sticky = true
show_notification("Private", "Weechat Private Message", message, sticky)
return Weechat::WEECHAT_RC_OK
end
def show_highlight(data, signal, message)
message[0..1] == '--' ? sticky = false : sticky = true
show_notification("Highlight", "Weechat", message, sticky)
return Weechat::WEECHAT_RC_OK
end
def show_notification(name, title, message, sticky = true)
@growl.notify({
:name => name,
:title => title,
:text => message,
:icon => "https://github.com/tinifni/gntp-notify/raw/master/weechat.png",
:sticky => sticky
})
end