Skip to content

Commit

Permalink
Added botman:listen command
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Dec 16, 2016
1 parent ba99f0f commit 3089aff
Show file tree
Hide file tree
Showing 6 changed files with 1,206 additions and 46 deletions.
56 changes: 56 additions & 0 deletions app/Console/Commands/BotManListen.php
@@ -0,0 +1,56 @@
<?php

namespace App\Console\Commands;

use App\Conversations\ExampleConversation;
use Illuminate\Console\Command;
use Mpociot\BotMan\BotManFactory;
use Mpociot\BotMan\Cache\LaravelCache;
use React\EventLoop\Factory;

class BotManListen extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'botman:listen';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Tell BotMan to listen with the Slack RTM API.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
/** @var \Illuminate\Foundation\Application $app */
$app = app('app');
$loop = Factory::create();

$app->singleton('botman', function ($app) use ($loop) {
return BotManFactory::createForRTM(config('services.botman', []), $loop, new LaravelCache());
});

require base_path('routes/botman.php');

$loop->run();
}
}
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Expand Up @@ -2,6 +2,7 @@

namespace App\Console;

use App\Console\Commands\BotManListen;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

Expand All @@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
BotManListen::class
];

/**
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -7,7 +7,8 @@
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"mpociot/botman": "~1.0"
"mpociot/botman": "~1.0",
"mpociot/slack-client": "^0.2.6"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down

0 comments on commit 3089aff

Please sign in to comment.