<?php
/*
کانال سورس خونه ! پر از سورس هاي ربات هاي تلگرامي !
لطفا در کانال ما عضو شويد 
@source_home
https://t.me/source_home
*/
echo '@Source_home';
ini_set("log_errors" , "off");
ob_start();
define('API_KEY','267127840:AAEIb9CXLiNthW1OUJTeqi2SeDbuvp5IWXA');
//فانکشن//
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);
    }
}

//متغیر//
$yourtext = "12341564996";
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$chat_id = $message->chat->id;
$from_id = $message->from->id;
$message_id = $update->callback_query->message->message_id;
$messag = $update->message;
$text = $message->text;
$remcom = file_get_contents("data/$from_id/command.txt");
$forward_chat_username = $update->message->forward_from_chat->username;
$forward_chat_msg_id = $update->message->forward_from_message_id;
$tc = $message->chat->type;
$reply = $update->message->reply_to_message;
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
@$matin = file_get_contents("data/$chat_id/matin.txt");
@mkdir("data/$chat_id");
@mkdir("Source_home");
@$list = file_get_contents("Member.txt");
$time = file_get_contents("http://api.lordmizban.ir/api/time.php");
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$chat_id = $message->chat->id;
$from_id = $message->from->id;
////====================
       $user = file_get_contents('Member.txt');
        $members = explode("\n", $user);
        if (!in_array($from_id, $members)) {
            $add_user = file_get_contents('Member.txt');
            $add_user .= $from_id . "\n";
            file_put_contents("data/$chat_id/Member.txt", "0");
            file_put_contents('Member.txt', $add_user);
        }
////
$timerem = file_get_contents("data/$from_id/reminder/time.txt");
$pmoram = file_get_contents("data/$from_id/reminder/pmoram.txt");
////


//فانکشن//
function sendmessage($chat_id, $text)
{
    bot('sendMessage', [
        'chat_id' => $chat_id,
        'text' => $text,
        'parse_mode' => "HTML"
    ]);
}

function deletemessage($chat_id, $message_id)
{
    bot('deletemessage', [
        'chat_id' => $chat_id,
        'message_id' => $message_id,
    ]);
}

function sendaction($chat_id, $action)
{
    bot('sendchataction', [
        'chat_id' => $chat_id,
        'action' => $action
    ]);
}

function Forward($KojaShe, $AzKoja, $KodomMSG)
{
    bot('ForwardMessage', [
        'chat_id' => $KojaShe,
        'from_chat_id' => $AzKoja,
        'message_id' => $KodomMSG
    ]);
}

function sendphoto($chat_id, $photo, $action)
{
    bot('sendphoto', [
        'chat_id' => $chat_id,
        'photo' => $photo,
        'action' => $action
    ]);
}

function objectToArrays($object)
{
    if (!is_object($object) && !is_array($object)) {
        return $object;
    }
    elseif (is_object($object)) {
        $object = get_object_vars($object);
    }
    return array_map("objectToArrays", $object);
}function editMessagetext($chat_id,$message_id,$text,$parse_mode,$disable_web_page_preview,$keyboard){
  bot('editMessagetext',[
    'chat_id'=>$chat_id,
 'message_id'=>$message_id,
    'text'=>$text,
    'parse_mode'=>$parse_mode,
 'disable_web_page_preview'=>$disable_web_page_preview,
    'reply_markup'=>$keyboard
 ]);
 }
function pinChatMessage($chat_id){
bot('pinChatMessage',[
'chat_id'=>$chat_id,
]);
}
if(preg_match('/^\/([Ss]tart)(.*)/',$text)){
if (!file_exists("data/$from_id/command.txt")) {
        mkdir("data/$from_id");
        $myfile2 = fopen("Member.txt", "a") or die("Unable to open file!");
        fwrite($myfile2, "$from_id\n");
        fclose($myfile2);
		}
    
	bot('sendmessage',[
	'chat_id'=>$chat_id,
	'text'=>"📱Welcome To Clock Bot.
....
❣You Live In Iran - Tehran.
...
🔋This Bot Source By @Source_home Team",
        'reply_to_message_id'=>$update->message->message_id,
        	'reply_markup'=>json_encode([
	'resize_keyboard'=>true,
	'keyboard'=>[
	[['text'=>"⏰"]],
	]
	])
	]);
	}
elseif($text == "⏰"){
bot('sendmessage',[
	'chat_id'=>$chat_id,
	'text'=>"Welcome To Your Clock.",
        'reply_to_message_id'=>$update->message->message_id,
        	'reply_markup'=>json_encode([
	'resize_keyboard'=>true,
	'keyboard'=>[
	[['text'=>"Time⏰"],['text'=>"Reminder🔔"]]
	]
	])
	]);
	}
	elseif($text == "Time⏰"){
bot('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⏰ $time",
	'pars_mode'=>'HTML',
	'reply_markup'=>json_encode(['inline_keyboard'=>[
	],'resize_keyboard'=>true])
	]);
}
elseif($text == "Reminder🔔"){
    file_put_contents("data/$from_id/command.txt","reminder");
	
	bot('sendmessage',[
    'chat_id'=>$chat_id,
    'text'=>"Type the time you want.
Example : 02:56",
    'parse_mode'=>'html',
    'reply_markup'=>json_encode([
      'keyboard'=>[
	  [['text'=>'Back🤯']],
      ],'resize_keyboard'=>true])
  ]);
}
elseif($remcom == "reminder"){
    file_put_contents("data/$from_id/command.txt","reminder2");
    file_put_contents("data/$from_id/reminder/time.txt","$text");
	
	bot('sendmessage',[
    'chat_id'=>$chat_id,
    'text'=>"Selected hour: $text
At AM time you want to be reminded or PM?",
    'parse_mode'=>'html',
    'reply_markup'=>json_encode([
      'keyboard'=>[
	  [['text'=>'PM'],['text'=>'AM']],
      ],'resize_keyboard'=>true])
  ]);
 } 
 if($remcom == "reminder2"){
    file_put_contents("data/$from_id/reminder/pmoram.txt","$text");
	file_put_contents("data/$from_id/command.txt","none");
	bot('sendmessage',[
    'chat_id'=>$chat_id,
    'text'=>"OK! You are reminded at $timerem $pmoram",
    'parse_mode'=>'html',
    'reply_markup'=>json_encode([
      'keyboard'=>[
	  [['text'=>'Back🤯']],
      ],'resize_keyboard'=>true])
  ]);
 } 
 elseif($time == "$timerem:00 $amorpm"){
    file_put_contents("data/$from_id/reminder/pmoram.txt","no");
	file_put_contents("data/$from_id/reminder/time.txt","no");
	bot('sendmessage',[
    'chat_id'=>$chat_id,
    'text'=>"Hey! Wake Up! The clock is $timerem $pmoram 🙄",
    'parse_mode'=>'html',
    'reply_markup'=>json_encode([
      'keyboard'=>[
	  [['text'=>'Close🤫']],
      ],'resize_keyboard'=>true])
  ]);
 } 
if($text == "Back🤯"){
bot('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"Type /start to back.",
	'pars_mode'=>'HTML',
	'reply_markup'=>json_encode(['inline_keyboard'=>[
	],'resize_keyboard'=>true])
	]);
	file_put_contents("data/$from_id/reminder/pmoram.txt","");
	file_put_contents("data/$from_id/reminder/time.txt","");
}
elseif($text == "Close🤫"){
bot('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"Closed.🔐",
	'pars_mode'=>'HTML',
	'reply_markup'=>json_encode(['inline_keyboard'=>[
	],'resize_keyboard'=>true])
	]);
}

unlink("error_log");
/*
کانال سورس خونه ! پر از سورس هاي ربات هاي تلگرامي !
لطفا در کانال ما عضو شويد 
@source_home
https://t.me/source_home
*/
?>