Commit 86678198 authored by Armando Lüscher's avatar Armando Lüscher

Fix generic message command to use new conversation methods.

parent 00bcf786
...@@ -24,7 +24,7 @@ class GenericmessageCommand extends SystemCommand ...@@ -24,7 +24,7 @@ class GenericmessageCommand extends SystemCommand
*/ */
protected $name = 'Genericmessage'; protected $name = 'Genericmessage';
protected $description = 'Handle generic message'; protected $description = 'Handle generic message';
protected $version = '1.0.1'; protected $version = '1.0.2';
protected $need_mysql = true; protected $need_mysql = true;
/**#@-*/ /**#@-*/
...@@ -46,15 +46,16 @@ class GenericmessageCommand extends SystemCommand ...@@ -46,15 +46,16 @@ class GenericmessageCommand extends SystemCommand
*/ */
public function execute() public function execute()
{ {
//System command, fetch command to execute if conversation exist //If a conversation is busy, execute the conversation command after handling the message
$message = $this->getMessage(); $conversation = new Conversation(
$chat_id = $message->getChat()->getId(); $this->getMessage()->getChat()->getId(),
$user_id = $message->getFrom()->getId(); $this->getMessage()->getFrom()->getId()
//Fetch Conversation if exist );
$command = (new Conversation($user_id, $chat_id))->getConversationCommand(); //Fetch conversation command if it exists and execute it
if (! is_null($command)) { if ($conversation->exists() && ($command = $conversation->getCommand())) {
return $this->telegram->executeCommand($command, $this->update); return $this->telegram->executeCommand($command, $this->update);
} }
return Request::emptyResponse(); return Request::emptyResponse();
} }
} }
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