404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.139.98.233: ~ $
<?php
class ChatmatEngine extends MessageProcessor {
	private $databseFriend;
	function __construct($botUsername,$botToken,$webhookUrl,$sign){
			parent::__construct($botUsername,$botToken,$webhookUrl,$sign);
		}
		public function setStep($step){
 			$moogleDb = new MoogleDatabaseHandler();
 			$moogleDb->updateStep($step,$this->user['id']);
		}
		public function processCallback($update){
			$callBackData= explode(":", $this->callback_data);
			if($callBackData[0] == "task" && $callBackData[1] == "get" && $callBackData[2] == "link"  ){
				$message = "لط�ا لینک کانال خود را وارد کنید";
				$this->setStep("gettingLink");
			}
// 			$this->apiRequest ( "answerCallbackQuery", array (
// 					'callback_query_id' => $this->callback_id,
// 					"text" => $message
// 			) );
// 			$this->apiRequest ( "sendMessage", array (
// 					'chat_id' => $this->chat_id,
// 					"text" => $message
// 			) );
		}

	public function processInlineQuery($update){
		$memberObject = $this->apiRequest ( "getChatMember", array (
				'chat_id' => "@loghatkad",
				'user_id' => $update['inline_query']['from']['id']
		) );
		$textQuery = $update['inline_query']['query'];
		if($memberObject['status']!="member" && $memberObject['status']!="administrator"){
			$this->apiRequest ( "sendMessage", array (
					'chat_id' => $update['inline_query']['from']['id'],
					"text" => "برای است�اده از لغتنامه از شما خواهشمندیم در این کانال loghatnameh عضو شوید، تا بتوانیم اطلاعات بیشتر را در اختیار شما قرار بدهیم"
					.PHP_EOL."https://t.me/loghatkad".PHP_EOL
			) );
			$cacheTime = 300;
			$readyResult =[[
			    "type" => "article",
			    "id" => "0",
			    "title" => $textQuery." باید عضو کانال باشید تا بتونین ترجمه کنید",
			    "message_text" => "برای است�اده از لغتنامه از شما خواهشمندیم در این کانال عضو شوید، تا بتوانیم اطلاعات بیشتر را در اختیار شما قرار بدهیم"
					.PHP_EOL."https://t.me/loghatkad".PHP_EOL
			  ]];
		}
		else if($textQuery=="invite"){
			$invitationText = "سلام دوست عزیزم
					این دعوتنامه است�اده از لغتنامه
					�ارسی به آلمانی
					و آلمانی به �ارسی هست.
					برای است�اده از لغت نامه باید روی لینک زیر کلیک کنی".PHP_EOL
					.PHP_EOL."https://telegram.me/translateGerman_bot?start=".$update['inline_query']['from']['id'].PHP_EOL;
			
			$invititionUrl= "https://telegram.me/translateGerman_bot?start=".$update['inline_query']['from']['id'];
			$markUp = [
					'inline_keyboard' => [[['text' =>  "باز کردن دعوتنامه", 'url' => $invititionUrl]]],
			];
// 			$markUp = json_encode($keyboard, true);
			$cacheTime = 0;
			$readyResult =[[
					"type" => "article",
					"id" => "0",
					"title" => "دعوتنامه ارسال شود",
					"message_text" => $invitationText,
					"reply_markup" => $markUp,
					"cache_time" => $cacheTime
			]];	
			
		}
		else {
		
			
			
			/*$result = [
				'InlineQueryResultArticle' => [[['type' =>  "article", 'id' => "43",'title' => "Translation",'message_text' => "translated"]]],
				 ];
					*/
			$translatedText =$this->translateWordProcess($textQuery);
			$readyResult =[[
			    "type" => "article",
			    "id" => "0",
			    "title" => $textQuery." ترجمه",
			    "message_text" => $translatedText.PHP_EOL."@TranslateGerman_bot",
				"cache_time" => 1
			  ]];
			 // $readyResult = json_encode($readyResult, true);

		}
		
					$this->apiRequest ( "answerInlineQuery", array (
					'inline_query_id' => $this->inline_message_id,
					'results' => $readyResult,
					'cache_time' => $cacheTime,
							
			) );
		
	}
	public function sendInvitation(){
		$keyboard = [
				'inline_keyboard' => [[['text' =>  "ارسال به دوستان", 'switch_inline_query' => "invite"]]],
		];
		$markup = json_encode($keyboard, true);
		$this->apiRequest ( "sendPhoto", array (
				'chat_id' => $this->message['from']['id'],
				'photo' => "https://www.musicerian.tk/autopost/images/loghatnameh.png",
				"caption" => "سلام دوست خوبم، این یک دعوتنامه از طر� من برای است�اده از لغتنامه �ارسی به آلمانی و آلمانی به �ارسی هست، با ارسال این دعوتنامه دوستان شما اجازه است�اده از لغتنامه را خواهند داشت   ",
				"reply_markup" =>$markup
		) );
	}
	public function sendMessageLog($msgLog){	
// 					$keyboard = [
// 							'inline_keyboard' => [[['text' =>  "معر�ی‌ به دوستان", 'switch_inline_query' => "invite"]]],
// 					];
// 					$markup = json_encode($keyboard, true);

				$this->apiRequest ( "sendMessage", array (
						'chat_id' => 44903244,
						"text" => $this->message['from']['id']."@@@".$this->message['from']['username']."--".$this->message['from']['first_name']." ".$this->message['from']['last_name']
						.PHP_EOL.$this->message ['text'].PHP_EOL."<a href='https://telegram.me/translateGerman_bot?start=hallo'>".$msgLog."</a>",
						"parse_mode" => "html",
						 "disable_web_page_preview" => true

				) );	
// 				,
// 				"reply_markup" =>$markup
	}
	public function processText($update) {
		// incoming text message
		$text = $this->message ['text'];
		if(strpos($text,"/start") === 0) {
			$startMessageParts = explode(" ", $text);
			if(!empty($startMessageParts[1])){
				$chatStart = "یک فرد جدید می خواهد با شما صحبت کند، لطفا پیام زیر را reply کنید تا مکالمه آغاز شود.";
				$this->sendMessage($chatStart, $startMessageParts[1]);
				$this->forwardMessage($startMessageParts[1]);
				
			}
			else {
				
				$yourLink = "لینک صفحه چت من".PHP_EOL;
				$yourLink .= "https://telegram.me/chatmatbot?start=".$this->user['id'];
				$this->sendMessage($yourLink,$this->user['id']);
			}
		}
		else  
		{
			
			$repliedTomessage = $this->message ['reply_to_message'];
			if (!empty($repliedTomessage ['forward_from']['id'])) {
				$this->forwardMessage($repliedTomessage ['forward_from']['id']);
			}
			else {
				$yourLink = "لینک صفحه چت من".PHP_EOL;
				$yourLink .= "https://telegram.me/chatmatbot?start=".$this->user['id'];
				$this->sendMessage($yourLink,$this->user['id']);
				
				$this->sendMessage("برای پاسخ به هر پیام باید ، همون پیغام رو reply کنی");
			}
				
		}
		
		$this->forwardMessageLog();
		
	}
	
	public function encodedUserId( $userId ){
		$userId = str_replace ( "1" , "a" , $userId );
		$userId = str_replace ( "2" , "b" , $userId );
		$userId = str_replace ( "3" , "c" , $userId );
		$userId = str_replace ( "4" , "d" , $userId );
		$userId = str_replace ( "5" , "e" , $userId );
		$userId = str_replace ( "6" , "f" , $userId );
		$encodedUserId = str_replace ( "7" , "g" , $userId );
		return $encodedUserId;
		
	}
	public function decodeUserId($encodedUserId){
		$userId = str_replace ( "a" , "1" , $userId );
		$userId = str_replace ( "b" , "2" , $userId );
		$userId = str_replace ( "c" , "3" , $userId );
		$userId = str_replace ( "d" , "4" , $userId );
		$userId = str_replace ( "e" , "5" , $userId );
		$userId = str_replace ( "f" , "6" , $userId );
		$decodeUserId = str_replace ( "g" , "7" , $userId );
		return (int)$decodeUserId;
	}
	public function getStep($userId) {
		$moogleDb = new MoogleDatabaseHandler();
		$moogleDb->insertUser($this->user['id'],$this->user['id']['username'],$this->user['id']['first_name'] ,$this->user['id']['last_name']);
		$moogleDb->getStep($userId);
		return "welcoming";
	}
	public function doThisStep($step) {
		
		switch ($step){
			case "welcoming":
				$this->sendWelcomeMsg();
// 				$this->sendCpanel();
				break;
			case "gettingLink":
				$this->checkingLink($link);
				$this->savingLinkAndAdmin($link,$admin);
				$this->sendNeedDescMsg();
				$this->sendCpanel();
				break;
			case "gettingDescription":
				$this->checkingDescription($desc);
				$this->savingDesc($link,$desc);
				$this->sendNeedSubjectsMsg();
				$this->sendExistedSubjects();
				$this->sendCpanel();
				break;
			case "gettingSubject":
				
				break;
			case "gettingAllowedHours":
				
				break;
			case "gettingPanel":
				
				break;
			case "addingNewSubject":
				
				break;
			case "confirmingNextPost":
				
				break;
				
		}
	
	}
	public function sendWelcomeMsg(){
		$text = "درود
				به ربات تبادل لینک و جستجوی لینک خوش آمدید
				برای شروع لینک کانال خود را وارد کنید";
		$keyboard = [
					'inline_keyboard' => [
							[['text' =>  "وارد کردن لینک", 'callback_data' => "task:get:link"]]],
		];
		$markup = json_encode($keyboard, true);

		$this->apiRequest ( "sendMessage", array (
				'chat_id' =>  $this->chat_id,
				"text" => $text,
				"parse_mode" => "html",
				"disable_web_page_preview" => true,
				"reply_markup" =>$markup
	
		) );

	}
	
	
}

Filemanager

Name Type Size Permission Actions
ChatmatDatabaseHandler.php File 9.18 KB 0755
ChatmatEngine.php File 13.04 KB 0755
chatmatbot.php File 4.39 KB 0755
install.php File 14 B 0755