Class: Repp::Handler::Slack
- Inherits:
-
Object
- Object
- Repp::Handler::Slack
show all
- Defined in:
- lib/repp/handler/slack.rb
Defined Under Namespace
Classes: SlackMessageHandler, SlackReceive
Constant Summary
collapse
- REPLY_REGEXP =
/<@(\w+?)>/
Class Method Summary
collapse
Class Method Details
.run(app, options = {}) {|_self| ... } ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/repp/handler/slack.rb', line 60
def run(app, options = {})
yield self if block_given?
::Slack.configure do |config|
config.token = detect_token
end
@client = ::Slack::RealTime::Client.new
@web_client = ::Slack::Web::Client.new
application = app.new
@ticker = Ticker.task(application) do |res|
if res.first
if res.last && res.last[:dest_channel]
channel_to_post = res.last[:dest_channel]
attachments = res.last[:attachments]
@web_client.chat_postMessage(text: res.first, channel: channel_to_post, as_user: true, attachments: attachments)
else
message = "Need 'dest_to:' option to every or cron job like:\n" +
"every 1.hour, dest_to: 'channel_name' do"
$stderr.puts(message)
end
end
end
@ticker.run!
handler = SlackMessageHandler.new(@client, @web_client, application)
handler.handle
end
|
.stop! ⇒ Object
88
89
90
|
# File 'lib/repp/handler/slack.rb', line 88
def stop!
@client.stop!
end
|