fordsmh / zanzara
Asynchronous PHP Telegram Bot Framework
dev-develop
2022-11-17 06:27 UTC
Requires
- php: >=7.3
- ext-json: *
- ext-readline: *
- clue/http-proxy-react: ^1.6
- netresearch/jsonmapper: ^4.0
- opis/closure: ^3.6
- php-di/php-di: ^7.x-dev
- php-http/multipart-stream-builder: ^1.1
- psr/container: ^2.0.2
- psr/log: ^1.1
- react/cache: ^1.1
- react/event-loop: ^1.1
- react/http: ^1.2
Requires (Dev)
- monolog/monolog: ^2.1
- phpunit/phpunit: ^9.5
- symfony/dotenv: ^5.2
This package is auto-updated.
Last update: 2025-03-17 11:26:26 UTC
README
Asynchronous PHP Telegram Bot Framework built on top of ReactPHP
Features
- Long polling support (no webserver required)
- Middleware chain for requests
- Conversations and sessions (no database required)
- Based on ReactPHP asynchronous non-blocking I/O model
- Scheduled functions/timers provided by ReactPHP
- Bulk message sending (no more 429 annoying errors)
Installation
composer require badfarm/zanzara
Quickstart
Create a file named bot.php
and paste the following code:
<?php use Zanzara\Zanzara; use Zanzara\Context; require __DIR__ . '/vendor/autoload.php'; $bot = new Zanzara("YOUR-BOT-TOKEN"); $bot->onCommand('start', function (Context $ctx) { $ctx->sendMessage('Hello'); }); $bot->run();
Then run it from command line as follows:
$ php bot.php
Enjoy your bot!
Check out the Wiki for documentation.