if(mb_strpos($text, "/setchannel") and $status!=="member"){
$ex = explode(" ", $text);
if (isset($ex[1])!==false) {
file_put_contents("channel/$chat_id.txt",$ex[1]);
$mychannel = file_get_contents("channel/$chat_id.txt");
bots('sendMessage', [
'chat_id'=>$chat_id,
'text'=>'Теперь не подписанные на ваш канал/чат('.$mychannel.') не могут писать в эту группу.',
]);
}else{
bots('sendMessage',[
'chat_id'=>$chat_id,
'text'=>'Непонтно что. Вот пример исползование данной команды: <code>/setchannel {
@username}</code>',
'parse_mode'=>'html'
]);
}
}
if (isset($mychannel)!==false) {
$use = bots('getChatMember', [
'chat_id'=>$mychannel,
'user_id'=>$sender_id
]);
$adm_bot = $use['ok'];
$statuses = $use['result']['status'];
$get = bots('getChat',['chat_id'=>$mychannel]);
$chan_user = $get['result']['username'];
$chan_name = $get['result']['title'];
if (isset($text)) {
if ($statuses=="administrator" or $statuses =="creator" or $statuses=="member") {}
}else{
Delete();
bots('restrictChatMember',[
'user_id'=>$sender_id,
'chat_id'=>$chat_id,
'can_post_messages'=>false,
'can_add_web_page_previews'=>false,
'can_send_other_messages'=>false,
'can_send_media_messages'=>false,
]);
file_put_contents("temp/$sender_id.txt", $sender_id);
$user_test = file_get_contents("temp/$sender_id.txt");
typing();
bots('sendMessage',[
'chat_id'=>$chat_id,
'text'=>"Дорогой мой друг [$name](
tg://user?id=$sender_id) \nКсожалению здесь не могут писать не подписавшие на наш канал!",
'reply_markup'=>json_encode([
'inline_keyboard'=>[['text'=>'Подписаться 📥', 'url'=>"
https://t.me/$chan_user"]],
[['text'=>'Проверить 🔍', 'callback_data'=>'test_chan']]
]),
]);
if($data == 'test_chan'){
if ($back_uid==$user_test) {
$take = bots('getChatMember',[
'chat_id'=>$mychannel,
'user_id'=>$back_uid
]);
$statuses = $take['result']['status'];
if ($statuses!=='left' or $statuses!=='kicked') {
bots('restrictChatMember',[
'user_id'=>$back_uid,
'chat_id'=>$chat_id,
'can_post_messages'=>true,
'can_add_web_page_previews'=>true,
'can_send_other_messages'=>true,
'can_send_media_messages'=>true,
]);
unlink("temp/$back_uid.txt");
bots('deleteMessage',['chat_id'=>$chat_id,'message_id'=>$back_mid]);
bots('answerCallBackQuery', [
'callback_query_id'=>$callback_id,
'text'=>'Спасибо за подписку🤗',
'show_alert'=>true
]);
}else{
bots('answerCallBackQuery',[
'callback_query_id'=>$callback_id,
'text'=>'Хммм...🤔 Вы еще не подписаны, подпишитесь 🙄👇',
'show_alert'=>true
]);
}
}else{
bots('answerCallBackQuery',[
'callback_query_id'=>$callback_id,
'text'=>'Мы вас не проверяем!🙂',
'show_alert'=>true
]);
}
}
}
}