Commit 449740ed authored by LONGMAN's avatar LONGMAN

Fixes

parent 6a14dd05
......@@ -23,20 +23,15 @@ class CalcCommand extends Command
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = $message->getText(true);
$text = preg_replace('/[^0-9\+\-\*\/\(\) ]/i', '', trim($text));
$compute = create_function('', 'return (' . trim($text) . ');' );
$data = array();
$data['chat_id'] = $chat_id;
$data['reply_to_message_id'] = $message_id;
$data['text'] = 0 + $compute();
$data['text'] = $this->compute($text);
$result = Request::sendMessage($data);
......@@ -44,5 +39,13 @@ class CalcCommand extends Command
}
protected function compute($text) {
$text = preg_replace('/[^0-9\+\-\*\/\(\) ]/i', '', trim($text));
$compute = create_function('', 'return (' . trim($text) . ');' );
$result = 0 + $compute();
return $result;
}
}
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