diff --git a/app/BotMan/Drivers/ConsoleDriver.php b/app/BotMan/Drivers/ConsoleDriver.php deleted file mode 100644 index 9aadd27..0000000 --- a/app/BotMan/Drivers/ConsoleDriver.php +++ /dev/null @@ -1,166 +0,0 @@ -event = Collection::make(); - $this->config = Collection::make($config); - $this->client = $client; - - $this->client->on('line', function ($line) { - $this->message = $line; - }); - } - - /** - * Return the driver name. - * - * @return string - */ - public function getName() - { - return self::DRIVER_NAME; - } - - /** - * Determine if the request is for this driver. - * - * @return bool - */ - public function matchesRequest() - { - return false; - } - - /** - * @param Message $message - * @return Answer - */ - public function getConversationAnswer(Message $message) - { - $index = (int)$message->getMessage() - 1; - - if ($this->hasQuestion && isset($this->lastQuestions[$index])) { - $question = $this->lastQuestions[$index]; - return Answer::create($question['name']) - ->setInteractiveReply(true) - ->setValue($question['value']) - ->setMessage($message); - } - return Answer::create($this->message)->setMessage($message); - } - - /** - * Retrieve the chat message. - * - * @return array - */ - public function getMessages() - { - return [new Message($this->message, 999, '#channel', $this->message)]; - } - - /** - * @return bool - */ - public function isBot() - { - return strpos($this->message, 'BotMan: ') === 0; - } - - /** - * @param string|Question|IncomingMessage $message - * @param Message $matchingMessage - * @param array $additionalParameters - * @return $this - */ - public function reply($message, $matchingMessage, $additionalParameters = []) - { - $questionData = null; - if ($message instanceof IncomingMessage) { - $text = $message->getMessage(); - } elseif ($message instanceof Question) { - $text = $message->getText(); - $questionData = $message->toArray(); - } else { - $text = $message; - } - - $this->client->writeln(self::BOT_NAME.': '.$text); - - if (!is_null($questionData)) { - foreach ($questionData['actions'] as $key => $action) { - $this->client->writeln(($key+1).') '.$action['text']); - } - $this->hasQuestion = true; - $this->lastQuestions = $questionData['actions']; - } - - return $this; - } - - /** - * Send a typing indicator. - * @param Message $matchingMessage - * @return mixed - */ - public function types(Message $matchingMessage) - { - $this->client->writeln(self::BOT_NAME.': ...'); - } - - /** - * Retrieve User information. - * @param Message $matchingMessage - * @return User - */ - public function getUser(Message $matchingMessage) - { - return new User($matchingMessage->getUser()); - } - - /** - * @return bool - */ - public function isConfigured() - { - return false; - } -} diff --git a/app/Console/Commands/BotManTinker.php b/app/Console/Commands/BotManTinker.php deleted file mode 100644 index cec28c3..0000000 --- a/app/Console/Commands/BotManTinker.php +++ /dev/null @@ -1,71 +0,0 @@ -singleton('botman', function ($app) use ($loop) { - $config = config('services.botman', []); - $botman = BotManFactory::create($config, new ArrayCache()); - - $stdio = new Stdio($loop); - $stdio->getReadline()->setPrompt('You: '); - - $botman->setDriver(new ConsoleDriver($config, $stdio)); - - - $stdio->on('line', function ($line) use ($botman) { - $botman->listen(); - }); - - return $botman; - }); - - require base_path('routes/botman.php'); - - $loop->run(); - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ab71966..a5ce491 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -17,7 +17,6 @@ class Kernel extends ConsoleKernel */ protected $commands = [ BotManListen::class, - BotManTinker::class, FacebookAddStartButtonPayload::class ]; diff --git a/composer.json b/composer.json index 5d81d05..1af95af 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "laravel/framework": "5.3.*", "mpociot/botman": "~1.0", "mpociot/slack-client": "^0.2.6", - "clue/stdio-react": "^1.0" + "clue/stdio-react": "^1.0", + "mpociot/botman-tinker": "^0.1.1" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index d21baf3..8433aa2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0f117124f4f6cb7c14c5229608728b41", + "content-hash": "50493505aeb27760d4ca20d160f79db4", "packages": [ { "name": "classpreloader/classpreloader", @@ -1077,6 +1077,57 @@ ], "time": "2017-02-26T21:51:40+00:00" }, + { + "name": "mpociot/botman-tinker", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/mpociot/botman-tinker.git", + "reference": "7aea32759e7280f28fe573be4d73dd183a356d01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpociot/botman-tinker/zipball/7aea32759e7280f28fe573be4d73dd183a356d01", + "reference": "7aea32759e7280f28fe573be4d73dd183a356d01", + "shasum": "" + }, + "require": { + "clue/stdio-react": "^1.0", + "illuminate/support": "~5.0", + "mpociot/botman": "^1.4", + "mpociot/slack-client": "^0.2.6", + "php": ">=5.6.0" + }, + "require-dev": { + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "~5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpociot\\BotManTinker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marcel Pociot", + "email": "m.pociot@gmail.com" + } + ], + "description": "BotMan tinker command for your Laravel BotMan project", + "homepage": "http://github.com/mpociot/botman-tinker", + "keywords": [ + "Botman", + "Tinker", + "bot", + "laravel" + ], + "time": "2017-04-03T15:32:21+00:00" + }, { "name": "mpociot/phpws", "version": "1.1", diff --git a/config/app.php b/config/app.php index 3871131..fc7a99e 100644 --- a/config/app.php +++ b/config/app.php @@ -167,6 +167,7 @@ * Package Service Providers... */ \Mpociot\BotMan\BotManServiceProvider::class, + \Mpociot\BotManTinker\BotManTinkerServiceProvider::class, /* * Application Service Providers...