/**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->configure('slack');
     $this->app->singleton(SlackBot::class, function ($app) {
         // Instiate the bot with a token
         $bot = new SlackBot(config('slack.token'));
         // Set config array
         $bot->setConfig(config('slack'));
         // Add reactors from config file
         foreach (array_keys(config('slack.reactors')) as $reactorClass) {
             $bot->addReactor(new $reactorClass());
         }
         // Return bot
         return $bot;
     });
 }
Esempio n. 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->bot->run();
 }
Esempio n. 3
0
 /**
  * Create a new command instance.
  *
  * @param  DanGreaves\SlackBot\SlackBot $bot
  * @return void
  */
 public function __construct(SlackBot $bot)
 {
     parent::__construct();
     $bot->setCommand($this);
     $this->bot = $bot;
 }
Esempio n. 4
0
 /**
  * Access a config key specifically for this reactor.
  *
  * @param  string $key
  * @param  mixed  $default
  * @return mixed
  */
 public function config($key, $default = null)
 {
     return $this->bot->config('reactors.' . get_class($this) . '.' . $key, $default);
 }