litaio / lita-slack

A Slack adapter for Lita.
MIT License
141 stars 130 forks source link

Development Help: How to subscribe lita to events? #125

Closed lizgene closed 6 years ago

lizgene commented 6 years ago

I'm having trouble finding documentation on how to implement Slack event subscription with lita. Does anyone have some example code? Specifically, I'd like lita to perform an action on the reaction_added event.

Right now, I've pretty much been relying on routes like this:

route(/:news:/, :save_news, help: { ":news:" => "Save a message for today's news brief."})
def save_news(response)
  save_message(response)
  response.reply("Message saved!")
end
lizgene commented 6 years ago

Nvm, I got it! Closing.

on :slack_reaction_added, :greet

def greet(payload)
  target = Source.new(room: payload[:room])
  robot.send_message(target, "Hello #{payload[:room]}!")
end