Answer the question
In order to leave comments, you need to log in
How to make access to the response message from the bot in the TG bot, only to those users who are registered in the array?
Hello.
It is necessary that the function check the username of the person who wrote with the username that is in the list, and if it matches, it returns the answer in the form of this same username
, so I wrote the condition:
case ($text=='Хочу прогноз погоды' and $username == user_access()):
$ANSWER = shape(2);
$keyboard = keyboard();
break;
function user_access(){
$name = array('Имя1', 'Имя2');
if (in_array($username, $name))
{
echo $username;
}
else
{
echo "Match not found";
}
return $name;
}
Answer the question
In order to leave comments, you need to log in
Thanks a lot for the solution: nokimaro , :
case ($text == 'Хочу прогноз погоды' && user_has_access($username)):
$ANSWER = shape(2);
$keyboard = keyboard();
break;
function user_has_access($username) {
return in_array($username, [
'user1',
'имя2',
'имя3',
'имя10',
]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question