Closed jrab89 closed 4 years ago
- Is this a reasonable structure? I didn't see anything in the README or examples to suggest otherwise
Looks reasonable to me.
config.token
doesn't seem to work. I get the following stack trace when I run my code:$ MY_SLACK_TOKEN=my-token-here bundle exec ruby my_slack_bot.rb Traceback (most recent call last): 7: from my_slack_bot.rb:25:in `<main>' 6: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/bot.rb:6:in `run' 5: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/bot.rb:10:in `instance' 4: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/app.rb:19:in `instance' 3: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/app.rb:19:in `new' 2: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/app.rb:4:in `initialize' 1: from /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot.rb:12:in `configure' /Users/jeff.rabovsky/.gem/ruby/2.6.5/gems/slack-ruby-bot-0.12.0/lib/slack-ruby-bot/app.rb:5:in `block in initialize': Missing ENV['SLACK_API_TOKEN']. (RuntimeError)
It should. Would be a bug.
But when I run my code like
SLACK_API_TOKEN=my-token-here bundle exec ruby my_slack_bot.rb
instead, it works as expected
Try to debug it, write a spec?
- It seems odd to have an empty subclass of
SlackRubyBot::Bot
. Is that the right way to combine and run multiple subclasses ofSlackRubyBot::Commands::Base
?
It's not necessary, just gives you a place to put your own code. You can instantiate an instance of SlackRubyBot::Bot
and it should just work.
Note that subclassing from base and auto-loading of commands could cause some potential problems with ordering of things, like #225.
config.token doesn't seem to work
~@jrab89 could I clarify on the above - did you mean you were trying to hardcode the API Token in the SlackRubyBot.configure
block?~ It looks like the code only supports defining the token via an ENV variable.
Duh, thanks for digging this up @wasabigeek. Care to PR support for config.token
and config.aliases
?
I'm working on a Slack bot where I have one subclass of
SlackRubyBot::Commands::Base
per file. I also have my logger and Slack token that gets set within a Rails initializer file. What I have is equivalent to:config.token
doesn't seem to work. I get the following stack trace when I run my code:But when I run my code like
SLACK_API_TOKEN=my-token-here bundle exec ruby my_slack_bot.rb
instead, it works as expectedSlackRubyBot::Bot
. Is that the right way to combine and run multiple subclasses ofSlackRubyBot::Commands::Base
?Thanks for your help