Skip to content

Releases: Mateodioev/telegram-bot-handler

Update telegram-bot-api

08 Apr 17:47
Compare
Choose a tag to compare

Add event support

06 Apr 04:39
Compare
Choose a tag to compare

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

01 Apr 21:29
Compare
Choose a tag to compare

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

01 Apr 16:55
Compare
Choose a tag to compare

Full integration with amphp

01 Apr 16:26
Compare
Choose a tag to compare

Fixed typo

18 Mar 03:25
51f6b5c
Compare
Choose a tag to compare

Full Changelog: v3.1.1...v3.1.3

make method public

13 Mar 05:02
Compare
Choose a tag to compare
v3.1.1

make executeCommand public

Add async support

13 Mar 01:27
Compare
Choose a tag to compare

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

12 Mar 21:36
Compare
Choose a tag to compare

Add middleware support

09 Mar 03:21
Compare
Choose a tag to compare
Pre-release

Full Changelog: v2.3...v3.0-beta