Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple events in a single configure block #16

Open
Altonymous opened this issue Nov 3, 2022 · 1 comment
Open

Handle multiple events in a single configure block #16

Altonymous opened this issue Nov 3, 2022 · 1 comment

Comments

@Altonymous
Copy link

Altonymous commented Nov 3, 2022

Could you give me an overview of where I could find the code that sets up event collection?

I looked through the code and couldn't figure out how it's being done. I think it would be great to be able to pass in multiple events that are similar in type.

Example

SlackRubyBotServer::Events.configure do |config|
  config.on :event, ['event_callback', ['pin_added', 'pin_removed']] do |event|

Right now I'm handling it like this..

SlackRubyBotServer::Events.configure do |config|
  config.on :event, ['event_callback'] do |event|
    event_type = event[:event][:type]

    case event_type
    when 'pin_added', 'pin_removed'
      # Do Pin Stuff
    when 'reaction_added', 'reaction_removed'
      # Do Reaction Stuff
    else
      # Do Log & Error Handling Stuff
    end

    { ok: true }
  end
end
@dblock
Copy link
Contributor

dblock commented Nov 3, 2022

This belongs in slack-ruby-bot-server-events, the code is here. I'll transfer the issue, this is a good idea.

@dblock dblock transferred this issue from slack-ruby/slack-ruby-bot-server Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants