Commit 4286cad3 authored by MBoretto's avatar MBoretto

Revert old change

parent 2b251c5a
......@@ -199,15 +199,7 @@ class Message extends Entity
public function getFullCommand()
{
if (substr($this->text, 0, 1) === '/') {
$no_EOL = strtok($this->text, PHP_EOL);
$no_space = strtok($this->text, ' ');
//try to understand which separator \n or space divide /command from text
if (strlen($no_space) < strlen($no_EOL)) {
return $no_space;
} else {
return $no_EOL;
}
return strtok($this->text, ' ');
} else {
return;
}
......@@ -281,8 +273,7 @@ class Message extends Entity
if ($without_cmd) {
$command = $this->getFullCommand();
if (!empty($command)) {
//$text = substr($text, strlen($command.' '), strlen($text));
$text = substr($text, strlen($command) + 1, strlen($text));
$text = substr($text, strlen($command.' '), strlen($text));
}
}
......
......@@ -30,7 +30,7 @@ class Telegram
*
* @var string
*/
protected $version = '0.21.1';
protected $version = '0.20.2';
/**
* Telegram API key
......
......@@ -82,26 +82,5 @@ class MessageTest extends TestCase
$this->assertEquals('help', $this->message->getCommand());
$this->assertEquals('/help@testbot some text', $this->message->getText());
$this->assertEquals('some text', $this->message->getText(true));
// /commmad\n text
$this->message = new Message($this->generateMessage("/help\n some text"), 'testbot');
$this->assertEquals('/help', $this->message->getFullCommand());
$this->assertEquals('help', $this->message->getCommand());
$this->assertEquals("/help\n some text", $this->message->getText());
$this->assertEquals(' some text', $this->message->getText(true));
// /command@bot\nsome text
$this->message = new Message($this->generateMessage("/help@testbot\nsome text"), 'testbot');
$this->assertEquals('/help@testbot', $this->message->getFullCommand());
$this->assertEquals('help', $this->message->getCommand());
$this->assertEquals("/help@testbot\nsome text", $this->message->getText());
$this->assertEquals('some text', $this->message->getText(true));
// /command@bot \nsome text
$this->message = new Message($this->generateMessage("/help@testbot \nsome text"), 'testbot');
$this->assertEquals('/help@testbot', $this->message->getFullCommand());
$this->assertEquals('help', $this->message->getCommand());
$this->assertEquals("/help@testbot \nsome text", $this->message->getText());
$this->assertEquals("\nsome text", $this->message->getText(true));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment