Unique identifier for the target chat or username of the target channel (in the format @channelusername)
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->start();
$messages_Messages = $MadelineProto->channels->getMessages(['channel' => InputChannel, 'id' => [InputMessage, InputMessage], ]);
$bot->command('/start', function () use ($bot) {
$bot->say('Старт!', [
[
'Продлить книгу',
]
]);
});
$bot->hear('Продлить книгу', function () use ($bot) {
$bot->setState('book');
$bot->say('Напишите номер книги.');
});
$bot
->state('book', ['Назад'])
->hear(['{default}'], function () use ($bot) {
// проверка и отправка заявки ...
$bot->say('Заявка отправлена!');
});
use Botify\Core\Bot;
require '/vendor/autoload.php';
$config = [
'database.check_tables' => true,
'database.driver' => 'mysql',
'database.path' => '/path/to/database.sqlite',
'database.host' => 'localhost',
'database.database' => 'botify',
'database.username' => 'botify',
'database.password' => 'hackme',
'database.charset' => 'utf8mb4',
'database.collation' => 'utf8mb4_unicode_ci',
'database.lazy' => true,
];
$bot = new Bot('1234567890:ABC_TOKEN', $config);
// обработчик команды "/answer"
$bot->command('/\/answer/', function () use ($bot) {
// для сообщения вида "/command 1 ответ"
// если сообщение вида "/command 1 тут несколько слов" метод parse() не подойдет
[$cmd, $number, $answer] = $bot->parse();
$bot->say("Команда: {$cmd}, номер: {$number}, ответ: {$answer}");
// добавим ответ в бд
$insert = [
'user_id' => $bot->user_id,
'number' => $number,
'answer' => $answer,
];
$bot->db->table('quiz')->insert($insert);
});
$bot->run();
$bot->setState('how_much_is');
$bot->state('how_much_is')
->hear('{default}', function () use ($bot) {
$count = (int) $bot->message;
$bot->say("Ты выполнил {$count} раз?");
}
)
// or
if ($bot->state_name == 'how_much_is' && $bot->message !== 'СТОП СЛОВО ДЛЯ ВЫХОДА ИЗ СТЕЙТА') {
// code...
} else {
$bot->clearState();
}
['text' => 'Переслать', 'callback_data' => 'phpfanatsuckcock'],