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

Make commands asynchronous by default #2

Open
chancancode opened this issue Nov 21, 2017 · 0 comments
Open

Make commands asynchronous by default #2

chancancode opened this issue Nov 21, 2017 · 0 comments

Comments

@chancancode
Copy link
Member

We want to change the semantics so that commands and interactions are executed synchronously (as opposed to putting it in a queue) by default. It should still be possible to opt into the current asynchronous behavior with something like this:

class MonkeyCommand < Slackathon::Command
  async def call
    {
      response_type: "ephemeral",
      attachments: [{
        callback_id: "monkey",
        text: "Please pick a style",
        actions: [{
          type: "button",
          text: "Click to use :see_no_evil:",
          name: "post_in_channel",
          value: "#{params[:text]} :see_no_evil:"
        }, {
          type: "button",
          text: "Click to use :hear_no_evil:",
          name: "post_in_channel",
          value: "#{params[:text]} :hear_no_evil:"
        }, {
          type: "button",
          text: "Click to use :speak_no_evil:",
          name: "post_in_channel",
          value: "#{params[:text]} :speak_no_evil:"
        }]
      }]
    }
  end

  async def post_in_channel(value)
    {
      response_type: "in_channel",
      delete_original: true,
      text: "<@#{params[:user][:id]}> said #{value}"
    }
  end
end

The async class method can store the symbols in an array on the class instance, and dispatch_* can check whether it should call the method synchronously.

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

1 participant