Class: Agents::SlackbotAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::SlackbotAgent
- Defined in:
- lib/huginn_slackbot_agent/slackbot_agent.rb
Instance Method Summary collapse
- #default_options ⇒ Object
- #receive(incoming_events) ⇒ Object
- #validate_options ⇒ Object
- #working? ⇒ Boolean
Instance Method Details
#default_options ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/huginn_slackbot_agent/slackbot_agent.rb', line 19 def { 'channel' => '#general', 'text' => 'It works', 'as_user' => true, 'attachments' => [] } end |
#receive(incoming_events) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/huginn_slackbot_agent/slackbot_agent.rb', line 37 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do = { channel: interpolated['channel'], as_user: interpolated['as_user'] } [:text] = interpolated['text'] if interpolated['text'].present? [:attachments] = interpolated['attachments'] if interpolated['attachments'].present? && interpolated['attachments'].any? client.chat_postMessage() end end end |
#validate_options ⇒ Object
28 29 30 31 |
# File 'lib/huginn_slackbot_agent/slackbot_agent.rb', line 28 def errors.add(:base, 'you need to specify the channel or user name') unless ['channel'].present? errors.add(:base, 'you need to specify the text or attachments list') unless ['text'].present? || ['attachments'].any? end |
#working? ⇒ Boolean
33 34 35 |
# File 'lib/huginn_slackbot_agent/slackbot_agent.rb', line 33 def working? received_event_without_error? end |