Description
❓ Support Question
<--
//Set Your api & id admin
$ToKeN = ""; // API KEY
$Dev = 00000000; // id admin
error_reporting(0);
define('API_KEY',$ToKeN);
//==================================================
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 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 SendMessagee($chat_id, $text){
bot('sendMessage',[
'chat_id'=>$chat_id,
'text'=>$text,
'parse_mode'=>'MarkDown'
]);
}
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 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
]);
}
function save($filename,$TXTdata){
$myfile = fopen($filename, "w") or die("Unable to open file!");
fwrite($myfile, "$TXTdata");
fclose($myfile);
}
//==================================================
$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.",]);
}}}
-->
Required Information
? | ! |
---|---|
Operating system | Cpanel |
PHP version | 7.2 |
Update Method | Webhook |
MySQL version |
Summary
Hello all dear friends.
I am a beginner and need your help.
I created the following code which sends messages to people.
The code works well but,
People who close their forwards, I can't send messages to them with the bot.
Where is the problem?