mehr-als-nix / telegram-bot
dev-main
2022-06-20 19:02 UTC
Requires
- php: ^7.0
- league/event: ^2.1
- react/http-client: ^0.4
- react/react: ^0.4
Requires (Dev)
- phpspec/phpspec: ^3.4
- phpunit/php-code-coverage: ^5.2
- phpunit/phpunit: ^6.2
- squizlabs/php_codesniffer: 3.0.*
This package is not auto-updated.
Last update: 2024-11-10 03:05:28 UTC
README
Classes for creating a bot for telegram
Example
#!/usr/bin/env php <?php require_once './vendor/autoload.php'; /** @var LoopInterface */ $loop = React\EventLoop\Factory::create(); $runner = new TelegramBot\ReactRunner($loop); $resolverFactory = new React\Dns\Resolver\Factory(); $resolver = $resolverFactory->create('8.8.8.8', $loop); $HttpClient = (new React\HttpClient\Factory)->create( $loop, $resolver ); $apiClient = new TelegramBot\APIPollClient(getenv('BOT_TOKEN'), $HttpClient); $bot = new TelegramBot\Bot($apiClient); $bot->addListener('/ping', new TelegramBot\Command\PingCommand); $runner->runBot($bot);