mehr-als-nix/telegram-bot

dev-main 2022-06-20 19:02 UTC

This package is not auto-updated.

Last update: 2024-10-27 02:46:32 UTC


README

Classes for creating a bot for telegram

Build Status Scrutinizer Code Quality Code Coverage

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);