Skip to content

Handle multiple events in a single configure block #16

Open
@Altonymous

Description

@Altonymous

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions