forked from markolson/linkbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnector.rb
More file actions
46 lines (36 loc) · 883 Bytes
/
connector.rb
File metadata and controls
46 lines (36 loc) · 883 Bytes
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
module Linkbot
class Connector
@@connectors = {}
attr_accessor :options
def initialize(options)
@options = options
@callbacks = []
end
def self.[](x)
@@connectors[x]
end
def self.collect
Dir["connectors/*.rb"].each {|file| load file }
end
def self.register(name, s)
@@connectors[name] = s
end
def onmessage(&block)
@callbacks << block
end
def invoke_callbacks(message,options = {})
@callbacks.each { |c| c.call(message,options) }
end
def send_messages(messages,options = {})
end
def periodic()
if @options["periodic"]
EventMachine::defer(proc {
Linkbot::Plugin.handle_periodic.each do |message|
send_messages(message[:messages], message[:options])
end
})
end
end
end
end