PHP code example of dasshit / icq_bot
1. Go to this page and download the library: Download dasshit/icq_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/ */
dasshit / icq_bot example snippets
onolog\Logger;
use Dasshit\IcqBot as ICQ;
$bot = new ICQ\Bot(
'TOKEN',
"https://api.icq.net/bot/v1",
log_level: Logger::DEBUG,
log_path: 'bot_' . date("h-i-s") . '.log'
);
$keyboard = new ICQ\Keyboard();
$keyboard->addButton(
new ICQ\Button(text: "Test 1", url: "https://yandex.ru/")
);
$keyboard->addRow(
[
new ICQ\Button(text: "Test 2", callbackData: "test"),
new ICQ\Button(text: "Test 3", callbackData: "test"),
new ICQ\Button(text: "Test 4", callbackData: "test")
]
);
$keyboard->addButton(
new ICQ\Button(text: "Test 5", url: "https://yandex.ru/")
);
$bot->command("/start", function (ICQ\Bot $bot, $event) {
$bot->logger->debug($event["type"]);
$chatId = $event["payload"]["chat"]["chatId"];
$bot->sendText(
$chatId,
"Hi, @[$chatId]"
);
});
$bot->onMessage(function ($bot, $event) {
$bot->logger->debug($event["type"]);
$chatId = $event["payload"]["chat"]["chatId"];
$bot->sendText(
$chatId,
"Message, @[$chatId]"
);
});
$bot->onEditedMessage(function ($bot, $event) {
$bot->logger->debug($event["type"]);
$chatId = $event["payload"]["chat"]["chatId"];
$bot->sendText(
$chatId,
"Edit, @[$chatId]"
);
});
$bot->pollEvents();