Closed poyaz closed 7 years ago
The command you need to override is GenericmessageCommand
In the execute
method you can then get the text and do with it what you want 👍
Sry i change file GenericmessageCommand
return Request::emptyResponse();
to return
Request::sendMessage($data);
but can't get message without '/'
This example execute
method in GenericmessageCommand
will simply return the entered text (which you can get with $this->getMessage()->getText();
):
public function execute()
{
$message = $this->getMessage();
return Request::sendMessage([
'chat_id' => $message->getChat()->getId(),
'text' => $message->getText(),
]);
}
sry dude, but nothing change.
should change any file like hook.php or ...
my GenericmessageCommand file:
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Commands\SystemCommand;
class GenericmessageCommand extends SystemCommand
{
protected $name = 'Genericmessage';
protected $description = 'Handle generic message';
protected $version = '1.0.2';
protected $need_mysql = true;
public function executeNoDb()
{
//Do nothing
return Request::emptyResponse();
}
public function execute()
{
$message = $this->getMessage();
return Request::sendMessage([
'chat_id' => $message->getChat()->getId(),
'text' => $message->getText(),
]);
}
}
Probably not using DB...?
ty @jacklul
I not using Db.
ty very much
@pooya-az Is it working now? What did you change to make it work?
I add your code in executeNoDb() because $need_mysql is true value
Hmm, executeNoDb
gets executed when there is no MySQL connection available.
If you don't use the MySQL database, just set $mysql
to false.
Glad to see that it's working for you 👍
@noplanman ty very much for answer my issue.
Hi,
first question
I want when user send message (without /commands) like:
then handle this message.
I just find handle message when user send like