Class: Pepito::Adapters::Slack
- Inherits:
-
Adapter
- Object
- Adapter
- Pepito::Adapters::Slack
- Defined in:
- lib/pepito/adapters/slack.rb
Overview
Adapter for slack
Instance Attribute Summary collapse
-
#client ⇒ Slack::RealTime::Client
readonly
Slack RealTime client.
Class Method Summary collapse
-
.configs ⇒ Array<Hash>
Configs needed for Slack.
Instance Method Summary collapse
-
#initialize(robot, config) ⇒ Slack
constructor
A new instance of Slack.
-
#run ⇒ void
Runs the slack client.
-
#send_messages(target, strings) ⇒ void
Send messages to slack.
-
#stop ⇒ void
Stops the client.
-
#topic(target, topic) ⇒ void
Set topic.
Constructor Details
#initialize(robot, config) ⇒ Slack
Returns a new instance of Slack.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pepito/adapters/slack.rb', line 30 def initialize(robot, config) super(robot, config) configure_slack_api @client = ::Slack::RealTime::Client.new @client.web_client.auth_test end |
Instance Attribute Details
#client ⇒ Slack::RealTime::Client (readonly)
Slack RealTime client
28 29 30 |
# File 'lib/pepito/adapters/slack.rb', line 28 def client @client end |
Class Method Details
.configs ⇒ Array<Hash>
Configs needed for Slack
16 17 18 19 20 21 22 23 |
# File 'lib/pepito/adapters/slack.rb', line 16 def configs [ { name: 'SLACK_API_TOKEN', required: true } ] end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Runs the slack client
43 44 45 |
# File 'lib/pepito/adapters/slack.rb', line 43 def run @client.start! end |
#send_messages(target, strings) ⇒ void
This method returns an undefined value.
Send messages to slack.
51 52 53 54 55 56 57 |
# File 'lib/pepito/adapters/slack.rb', line 51 def (target, strings) = '' strings.each do |s| = + s + "\n" end @client.(channel: target.room, text: ) end |
#stop ⇒ void
This method returns an undefined value.
Stops the client
68 69 70 |
# File 'lib/pepito/adapters/slack.rb', line 68 def stop @client.stop! end |
#topic(target, topic) ⇒ void
This method returns an undefined value.
Set topic
62 63 64 |
# File 'lib/pepito/adapters/slack.rb', line 62 def topic(target, topic) @client.web_client.channels_setTopic(channel: target.room, topic: topic) end |