Module: SlackMessageAbilities
- Included in:
- SkillActions
- Defined in:
- src/abilities/slack_message_abilities.rb
Instance Method Summary collapse
-
#react_with(reaction) ⇒ void
React to the last user message in the interaction.
-
#say(text, vars: nil, channel: nil, thread: nil) ⇒ Message
(also: #reply, #reply_with)
Send a Slack message.
Instance Method Details
#react_with(reaction) ⇒ void
This method returns an undefined value.
React to the last user message in the interaction
The same as Message#react_with applied on Context#last_message.
72 73 74 75 76 |
# File 'src/abilities/slack_message_abilities.rb', line 72 def react_with(reaction) raise 'Cannot react before a message is received' unless context. context..react_with reaction end |
#say(text, vars: nil, channel: nil, thread: nil) ⇒ Message Also known as: reply_with ,
Send a Slack message
In a non-direct message channel sends the message in a thread on the last received user message for the interaction.
In a direct message or if channel is changed by SkillActions#in_channel, sends the message directly.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'src/abilities/slack_message_abilities.rb', line 38 def say(text, vars: nil, channel: nil, thread: nil) channel, thread = response_defaults channel, thread text = any_string text.to_s.split('.') if text.is_a? Symbol text = text % vars if vars response = @app.client.web_client.chat_postMessage( text: text, channel: channel, thread_ts: thread, as_user: true ) logger.info "Sent message '#{text}' to '#{channel}'#{thread && ":#{thread}"}" Message.new( @app, response..type, response.channel, response..thread_ts, response..user || response..bot_id, response..text, response.ts ) end |