git ssb

0+

dangerousbeans / scuttle_god



Tree: 37d877810de4ac575152439cf1ddabb2ad8d3788

Files: 37d877810de4ac575152439cf1ddabb2ad8d3788 / sbot_notifier.rb

842 bytesRaw
1# Send a notice to ssb as current user.
2#
3
4module God
5 module Contacts
6
7 class SbotNotifier < Contact
8
9 class << self
10 attr_accessor :channel
11 end
12
13 def valid?
14 valid = true
15 valid &= complain("Attribute 'channel' must be specified", self) unless arg(:channel)
16 valid
17 end
18
19 attr_accessor :channel
20
21 def notify(message, time, priority, category, host)
22 data = {
23 :message => message,
24 :time => time,
25 :priority => priority,
26 :category => category,
27 :host => host
28 }
29
30 `sbot publish --type post --text "#{message}" --channel #{arg(:channel)}`
31
32 rescue Object => e
33 applog(nil, :info, "failed to send sbot: #{e.message}")
34 applog(nil, :debug, e.backtrace.join("\n"))
35 end
36
37 end
38
39 end
40end
41

Built with git-ssb-web