-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpnotify.rb
More file actions
54 lines (46 loc) · 1.42 KB
/
Copy pathpnotify.rb
File metadata and controls
54 lines (46 loc) · 1.42 KB
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
# - pnotify.rb
# pnotify.rb is a script for Weechat that sends highlight notifications and private messages to the Prowl notification API.
# see http://prowl.weks.net/
# It uses the ruby gem prowl
#
# sudo gem install prowl
# cp pnotify.rb ~/.weechat/ruby/autoload/
def load_prowl
require 'stringio'
require 'rubygems'
require 'prowl'
#for mac os x only
$: <<
'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8' <<
'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0'
# TODO Handle the error more quitly
old_stdout = $stdout
$stdout = StringIO.new
$stdout = old_stdout
end
def weechat_init
Weechat.register("pnotify","plop@example.com", "0.2", "GPL3", "Notify user via prowl", "", "")
load_prowl
Weechat.hook_signal("weechat_pv","prowl_private_message", "")
Weechat.hook_signal("weechat_highlight", "prowl_highlight", "")
return Weechat::WEECHAT_RC_OK
end
def prowl_highlight(data, signal, msg)
title = "Highlight on #{data} #{signal}"
message = "#{msg}"
send_prowl(title,message)
return Weechat::WEECHAT_RC_OK
end
def prowl_private_message(data, signal, msg)
title = "Private message #{data} #{signal}:"
message = "#{msg}"
send_prowl(title,message)
return Weechat::WEECHAT_RC_OK
end
def send_prowl(title, message)
Prowl.add("your api key here", {
:application => "Weechat",
:event => title,
:description => message
})
end