I want to restrict my BOT to certain groups only. I can do that by checking the chat id against the group id. But the problem is I have too many commands and I don't want to add access code to each of the PHP scripts.
I want to implement the code on a single page, like the hook. But how can I do that in the hook or in any other single page?
This should put you in right direction:
$POST = file_get_contents("php://input");
$POST_DATA = json_decode($POST, true);
$user_id = null;
if (isset($POST_DATA['message']['chat']['id'])) {
$user_id = $POST_DATA['message']['chat']['id'];
}
$allowed = [];
if (!in_array($user_id, $allowed)) {
exit;
}
You will have to modify it a bit to consider other types of updates.
The code should be before handling the webhook in hook script.
I like this very much, would be cool to implement this into the manager 馃槆
Most helpful comment
This should put you in right direction:
You will have to modify it a bit to consider other types of updates.
The code should be before handling the webhook in hook script.