Сделать несколько админов в telegram bot
подскажите пожалуйста как сделать несколько админов в telegram bot
$bot->command("start", function ($message) use ($bot) {
$cid = $message->getChat()->getId();
if($cid == '308194279') // Как правильно добавит сюда несколько админов /
//есть переменная $id она выводит 308194279,408194279,408194279 (Но оно так не работает)
{
$bot->sendMessage($message->getChat()->getId(), "Все ок");
}
else
{
$bot->sendMessage($message->getChat()->getId(), "Тебе сюда нельзя.".$cid."");
}
});
Ответы (2 шт):
Автор решения: MoloF
→ Ссылка
Функция in_array() возвращает Boolean значение если элемент найден.
<?php
const AdministrationIdentifiers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
$myId = 1;
if (in_array($myId, AdministrationIdentifiers)) {
echo "Access granted";
} else {
echo "Access denied";
}
Автор решения: PunyFlash
→ Ссылка
$bot->command("start", function ($message) use ($bot) {
$cid = $message->getChat()->getId();
if(in_array($cid, ['308194279', '408194279', '408194279'])) {
$bot->sendMessage($message->getChat()->getId(), "Все ок");
}
else {
$bot->sendMessage($message->getChat()->getId(), "Тебе сюда нельзя.".$cid."");
}
});