Skip to content

Commit

Permalink
Corrected deprecated 'line' event and writeln method calls (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmuntzing authored and mpociot committed Oct 26, 2018
1 parent b60b354 commit 861800a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Commands/Tinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handle()

$botman->setDriver(new ConsoleDriver($config, $stdio));

$stdio->on('line', function ($line) use ($botman) {
$stdio->on('data', function ($line) use ($botman) {
$botman->listen();
});

Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/ConsoleDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function __construct(array $config, Stdio $client)
$this->config = Collection::make($config);
$this->client = $client;

$this->client->on('line', function ($line) {
$this->message = $line;
$this->client->on('data', function ($line) {
$this->message = rtrim($line, "\r\n");
});
}

Expand Down Expand Up @@ -114,7 +114,7 @@ public function isBot()
*/
public function types(IncomingMessage $matchingMessage)
{
$this->client->writeln(self::BOT_NAME.': ...');
$this->client->write(self::BOT_NAME.': ...'.PHP_EOL);
}

/**
Expand Down Expand Up @@ -163,11 +163,11 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam
public function sendPayload($payload)
{
$questionData = $payload['questionData'];
$this->client->writeln(self::BOT_NAME.': '.$payload['text']);
$this->client->write(self::BOT_NAME.': '.$payload['text'].PHP_EOL);

if (! is_null($questionData)) {
foreach ($questionData['actions'] as $key => $action) {
$this->client->writeln(($key + 1).') '.$action['text']);
$this->client->write(($key + 1).') '.$action['text'].PHP_EOL);
}
$this->hasQuestion = true;
$this->lastQuestions = $questionData['actions'];
Expand Down

0 comments on commit 861800a

Please sign in to comment.