سلام به همه دوستان عزیز.
من یک مبتدی هستم و به کمک شما نیاز دارم.
کد زیر را ایجاد کردم که به افراد پیام ارسال میکند.
کد به خوبی کار میکند، اما،
افرادی که فوروارد خود را بستهاند، نمیتوانم با ربات به آنها پیام ارسال کنم.
مثلا شخصی بهم در ربات پیام میدهد ولی چون فوروارد مسج اون قفل است من نمیتوانم بهش جواب بدهم
تشکر
//Set Your api & id admin
$ToKeN = ""; // API KEY
$Dev = 000000000; // id admin
error_reporting(0);
define('API_KEY',$ToKeN);
//==================================================
function sendMessage($chatidr,$text){
$url = 'https://api.telegram.org/bot'.API_KEY.'/sendMessage?';
$array = array('chat_id'=> $chatidr, 'text'=> $text);
$ch = curl_init();
$optArray = array(CURLOPT_URL =>$url, CURLOPT_POST => true,
CURLOPT_POSTFIELDS =>$array,CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $optArray);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result,true);
}
function getChatMember($chatidr,$userid){
$url = 'https://api.telegram.org/bot'.API_KEY.'/getChatMember?';
$array = array('chat_id'=> $chatidr, 'user_id'=> $userid);
$ch = curl_init();
$optArray = array(CURLOPT_URL =>$url, CURLOPT_POST => true,
CURLOPT_POSTFIELDS =>$array,CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $optArray);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result,true);
}
///=============================================================================
function bot($method,$datas=[]){
$url = "https://api.telegram.org/bot".API_KEY."/".$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$datas);
$res = curl_exec($ch);
if(curl_error($ch)){
var_dump(curl_error($ch));
}else{
return json_decode($res);
}
}
function Forward($chat_id,$from_id,$massege_id){
bot('ForwardMessage',[
'chat_id'=>$chat_id,
'from_chat_id'=>$from_id,
'message_id'=>$massege_id
]);
}
function SendAction($chat_id, $action){
bot('sendchataction',[
'chat_id'=>$chat_id,
'action'=>$action
]);
}
//==================================================
$update = json_decode(file_get_contents('php://input'));
//==================================================
$msg = $update->message;
$fWd = $update->forward_from->message->from->username;
$text = $msg->text;
$chat_id = $msg->chat->id;
$from_id = $msg->from->id;
$message_id = $msg->message_id;
$forward_from = $update->message->forward_from;
$forward_chat = $update->message->forward_from_chat;
$caption = $update->message->caption;
$step = file_get_contents("data/$Dev/step.txt");
$done = file_get_contents('data/done.txt');
$button = file_get_contents("data/button.txt");
$id = file_get_contents('data/id.txt');
$yourinfo = file_get_contents('data/yourinfo.txt');
$first_name = $msg->from->first_name;
$last_name = $msg->from->last_name;
$username = $msg->from->username;
$userch = $update->message->forward_from_chat->username;
$fwdfrom = $update->message->forward_from->username;
//-------------------------------------------------------
$forward = $update->message->forward_from;
$tc = $update->message->chat->type;
$rt = $update->message->reply_to_message->forward_from->id;
$rtn = $update->message->reply_to_message->forward_from->first_name;
$rtu = $update->message->reply_to_message->forward_from->username;
$rtid = $update->message->reply_to_message->from->id;
$from_chat_id = $forward_from_chat->id;
//---------------End AnTi Flood
if ($text == "/start" && $from_id == $Dev) {
save("data/$Dev/step.txt","none");
SendAction($chat_id, 'typing');
bot('SendMessage',[
'chat_id'=>$chat_id,
'text'=>"hi $first_name $last_name Welcome to your robot! username: $username id: $chat_id",]);
}
elseif($rt != "" && $from_id == $Dev){
bot('sendphoto',['chat_id'=>$rt,'photo'=>$photo0_id,'caption'=>$caption]);
SendAction($chat_id, 'typing');
bot('sendMessage',[
'chat_id'=>$rt,
'text'=>$text,
'parse_mode'=>'MarkDown',
]);
bot('sendMessage',[
'chat_id'=>$chat_id,
'text'=>"Dear * The desired message has been sent.",
'parse_mode'=>'MarkDown',
]);
}
else {
if ($from_id !== $Dev && !in_array($from_id,$banlist))
{
if($tc == "private"){
bot("forwardmessage",[
'chat_id'=>$Dev,
'from_chat_id'=>$chat_id,
'message_id'=>$message_id,
]);
bot('sendMessage',[
'chat_id'=>$chat_id,
'text'=>" $first_name, $last_name Your message was sent successfully.",]);
}}}
به علی کمک کنید تا مشکل خودش را حل کند؛ اینطور میتوانیم با هم پیشرفت کنیم.
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟