/TelegramBot

Classes for creating a bot for telegram

Primary LanguagePHPApache License 2.0Apache-2.0

TelegramBot

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