Releases: Mateodioev/telegram-bot-handler
Releases · Mateodioev/telegram-bot-handler
Update telegram-bot-api
Full Changelog: v3.3.0...v3.3.1
Add event support
Now you can handle events
use Mateodioev\TgHandler\Events\Types\MessageEvent;
use Mateodioev\Bots\Telegram\Api;
use Mateodioev\TgHandler\Context;
class MessageEventHandler extends MessageEvent
{
public function execute(Api $bot, Context $context, array $args = [])
{
// handle all message events
if ($context->getMessageText() == 'Hello') {
$bot->replyTo($context->getChatId(), 'Hi!', $context->getMessageId());
}
}
}
Now MessageEventHandler
can handle all incomming messages, only you need to add to your bot with method onEvent
$bot->onEvent(new MessageEventHandler);
Full Changelog: v3.2.2...v3.3.0
Closure message comand
Create new MessageCommand
instance from closure
Old
class MyCommand extends MessageCommand
{
protected string $name = 'start';
protected array $prefix = ['/', '!'];
public function handle(Api $bot, Context $context, array $args = [])
{
// Your logic here
}
}
$bot->on('message', MyCommand::get());
New
$bot->onCommand('start', function (Api $bot, Context $ctx, array $args = []) {
// Your logic here
})->setPrefixes(['/', '!']);
Fixed unnecesary middlewares call
Full Changelog: v3.2.0...v3.2.1
Full integration with amphp
Full Changelog: v3.1.3...v3.2.0
Fixed typo
Full Changelog: v3.1.1...v3.1.3
make method public
v3.1.1 make executeCommand public
Add async support
You can pass true to param async in methods Mateodioev\TgHandler\Bot::byWebhook
or Mateodioev\TgHandler\Bot::longPolling
Example
$bot->longPolling(30, async: true);
Middleware support
Full Changelog: v2.3...v3.0
Add middleware support
Full Changelog: v2.3...v3.0-beta