fink3l/yatb

YATB Yet Another Telegram Bot api

dev-master 2018-03-07 06:23 UTC

This package is not auto-updated.

Last update: 2024-05-16 18:05:35 UTC


README

Yet another telegram bot api implementation

Usage

$factory = new ApiModelFactory();
$api = new Api('bot-token');
$generator = new ApiUpdateGenerator(Update::class, $factory, $api);

foreach ($generator->getUpdates() as $update) {
    // do something with update
}

TestGenerator component

interchangeable components
$fakeGenerator = new FakeUpdateGenerator(Update::class, $factory);

foreach ($fakeGenerator->getUpdates() as $fakeUpdate) {
    // do something with fake updates
}
use components separately or build your awesome monstro good object telegram client
$webhook = new WebhookManager(Update::class, $factory, $api);

$client = new Client(random_int(0, 1) ? $generator : $fakeGenerator, $webhook);

$client->setWebhook('.../weebhook');
$update = $client->handleWebhook($request);
// do something with update

$client->stopWebhook();

foreach ($client->getUpdates() as $fakeUpdate) {
    // do something with fake updates
}