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

Are slash commands supported? #68

Open
johnhenriksson opened this issue Apr 25, 2016 · 8 comments
Open

Are slash commands supported? #68

johnhenriksson opened this issue Apr 25, 2016 · 8 comments

Comments

@johnhenriksson
Copy link

Just started using this gem, fantastic!

I use @bot [command] but would like to use /[command] just like /giphy [gifname]

Is this supported? Thanks!

@dblock
Copy link
Collaborator

dblock commented Apr 25, 2016

Slash commands are not supported out of the box, partly because this is usually implemented with a web front-end. I'll label this as a feature request though.

@johnhenriksson
Copy link
Author

Thanks! Is it supported in https://github.com/dblock/slack-bot-server ?
Maybe it belongs there because of the web front-end.

2016-04-25 16:41 GMT+02:00 Daniel Doubrovkine (dB.) @dblockdotorg <
notifications@github.com>:

Slash commands are not supported out of the box, partly because this is
usually implemented with a web front-end. I'll label this as a feature
request though.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/dblock/slack-ruby-bot/issues/68#issuecomment-214365139

@dblock
Copy link
Collaborator

dblock commented Apr 25, 2016

Not really. You have all the parts to build it there though.

What I'd like is a DSL and documentation on how to support slash commands in slack-ruby-bot. Implementing something in slack-bot-server is how I'd start with it and then see what it looks like and how to make this a feature of slack-ruby-bot.

@mabdelfattah
Copy link

Is it supported now?

@dblock
Copy link
Collaborator

dblock commented May 30, 2017

No, please feel free to contribute @mabdelfattah.

@mcconkiee
Copy link

out of the box, is there a way to ignore slash commands? in my case, i've an app that handles slash commands from the slack API, but i also have a bot using this library that seems to catch all these slash commands and responds with I don't understand that command! - just looking for catch all

@mcconkiee
Copy link

mcconkiee commented Feb 11, 2018

ahh nevermind...

match /^\/(.*)/ do |client, data, match|
    cmd = data['text']
    client.say(channel: data.channel, text: "ignoring slash commands: #{cmd}")
  end

that'll work !

@LouisKottmann
Copy link

I actually manage to call slash commands from my bot like this:

Create a helper method that reverts the token to a "legacy" one (they start with xoxp instead of xoxb):

def self.with_legacy_token(client)
        old_token = client.token
        begin
          client.token = ENV['SLACK_LEGACY_TOKEN']
          client.web_client.token = client.token

          yield(client)

        ensure
          client.token = old_token
          client.web_client.token = client.token
        end
      end

Then you can call slash commands like this:

Lib::GeneralHelper.with_legacy_token(client) do |legacy_client|
                    legacy_client.web_client.chat_command(channel: data.channel,
                                                          command: slash_cmd,
                                                          text: slash_cmd_arg)
                  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants