1. Go to this page and download the library: Download naftali100/async_bot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
naftali100 / async_bot example snippets
use bot_lib\Server;
$server = new Server("127.0.0.1:8080"); // create server instance listening to port 8080
$server->load_file("bot.php"); // load the handlers in "bot.php" and store them in "bot.php" path
$server->load_file("bot1.php", "index"); // you can add second param for different path
$server->load_folder("folder", true); // load all files in a folder. the second param is whether to load recursively or not
$server->run();
use bot_lib\Config;
use bot_lib\Handler;
use bot_lib\Update;
use bot_lib\Filter;
$config = new Config;
$config->load("conf.json"); // can store token
$config->server_url = "http://loadlhost:8081/bot"; // if you using local telegram-bot-api
$handler = new Handler;
$handler->on_message(
fn(Update $u) => $u->reply("hello"),
Filter::Message('/start')
);
$handler->on_message(
filter: "blabal",
func: fn($u) => $u->reply("bla"),
last: true,
name: 'reply bla to blabla'
);
use Psr\Log\LogLevel;
$server->setLogLevel(LogLevel::DEBUG);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.