404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.223.3.50: ~ $
<?php
// namespace Yandex\Translate;

class NewsCore extends MessageProcessor {
	private $databseFriend;
	function __construct($botUsername,$botToken,$webhookUrl,$sign){
			parent::__construct($botUsername,$botToken,$webhookUrl,$sign);
			$this->databseFriend = new NewsDatabaseHandler($this->botUsername);
		}
		public function getMoreContent($newsId){
			$news=$this->databseFriend->getNewsFromDbById($newsId);
			$miniCurl = new MiniCurl($news['link']);
			return $miniCurl->getData();
		}
		public function processCallback($update){
//  			$testMessage = var_export ( $update, true );
// 			file_put_contents ( "testbotprocessCallback.html", $testMessage, FILE_APPEND | LOCK_EX );
// 			$this->apiRequest ( "answerInlineQuery", array (
// 					'inline_query_id' => $this->chat_id,
// 					"results" => $this->callback_data
// 			) );
			$callBackData= explode(":", $this->callback_data);
			if($callBackData[0] == "task" && $callBackData[1] == "more" ){
				$message = " ادامه خبر";
				$newsId=$callBackData[2];
				$newsContent = $this->getMoreContent($newsId);
				$regex ='/articleBody\s[^&]*p>(.*)<\/strong>/';
				if (preg_match_all ( $regex, $newsContent, $matches )) {
					$moreText = $matches [1] [0];
				}
				$moreText = str_replace("<strong>", "", $moreText);
				$moreText = str_replace("<em>", "", $moreText);
				$moreText = str_replace("<", "", $moreText);
				$moreText = str_replace("</em", "", $moreText);
// 				$testMessage = var_export ( $newsContent, true );
// 				file_put_contents ( "testgrabdata.html", $testMessage, FILE_APPEND | LOCK_EX );
				$message.=PHP_EOL.PHP_EOL.$moreText;
			}
			else if($callBackData[0] == "task" && $callBackData[1] == "translate"){
				
// 				$key = "trnsl.1.1.20161227T200147Z.ea68ee52a784814b.d57d90672c621ed4b707e054a845d8e0367ad95d";
// 				$translated = file_get_contents("https://translate.yandex.net/api/v1.5/tr.json/translate?key="
// 				 		.$key."&lang=de-fa&text=abmachen");

				
				$key="trnsl.1.1.20161227T200147Z.ea68ee52a784814b.d57d90672c621ed4b707e054a845d8e0367ad95d";
				$translator = new Translator($key);
				$message = $translator->translate($this->message['text'], "de-fa");
				$message .= " ";

			}
			else if($callBackData[0] == "task" && $callBackData[1] == "approve"){
				$postbaker = new PostBaker ( $this->botUsername, $this->BOT_TOKEN, $this->sign );
				$postbaker->postNews( $this->message );


					
				$this->apiRequest ( "sendMessage", array (
						'chat_id' => $this->chat_id,
						"text" => $message,
						"reply_to_message_id" => $this->message['message_id']
						));
				
				 				$keyboard = [
				 						'inline_keyboard' => [[['text' =>  "ارسال شد", 'callback_data' => "task:nothing:nothing"]]],
				 				];
// 				$keyboard = [
// 						'inline_keyboard' => [[]],
// 				];
				$markup = json_encode($keyboard, true);
				$message = "ترجمه خبر در کانال قرار داده شد";
				$this->apiRequest ( "editMessageReplyMarkup", array (
						'chat_id' => $this->chat_id,
						"message_id" => $this->message['message_id'],
						'reply_markup' => $markup
						
				) );
// 				$this->apiRequest ( "editMessageText", array (
// 						'chat_id' => $this->chat_id,
// 						"message_id" => $this->message['message_id'],
// 						'text' => $message
						
// 				) );
				

				$this->apiRequest ( "sendMessage", array (
						'chat_id' => $callBackData[2],
						"text" => $message
				) );
			}
			else if($callBackData[0] == "task" && $callBackData[1] == "deny"){
				$message = "ترجمه خبر نیاز به اصلاح دارد";
				$this->apiRequest ( "sendMessage", array (
						'chat_id' => $callBackData[2],
						"text" => $message,
						"reply_to_message_id" => $this->message['message_id']
				) );
			}
			$this->apiRequest ( "answerCallbackQuery", array (
					'callback_query_id' => $this->callback_id,
					"text" => "اضافه شد"
			) );
			$this->apiRequest ( "sendMessage", array (
					'chat_id' => $this->chat_id,
					"text" => $message,
					"reply_to_message_id" => $this->message['message_id']
			) );
		}
	public function processText($update) {
		// incoming text message
		$text = $this->message ['text'];
		if(!empty($this->message ['reply_to_message']))
			$repliedTomessage = $this->message ['reply_to_message'];
		if (! empty ( $repliedTomessage ['text'] ) && !empty($repliedTomessage['entities'][1]['url'])) {
			
			$postbaker = new PostBaker ( $this->botUsername, $this->BOT_TOKEN, $this->sign );
			$postbaker->sendToApproveGroup ( $repliedTomessage, $this->message ['text'].var_export($repliedTomessage) );
			
		} else if(! empty ( $repliedTomessage ['text'] ) && empty($repliedTomessage['entities'][1]['url'])) {
			$reply = explode ( "@", $repliedTomessage ['text'] );
			if($text== "leaveGroup")
				if(!empty($reply [1])){					
					$this->apiRequestWebhook ( "leaveChat", array (
							'chat_id' => $reply [1]
					) );
				}
			$this->apiRequestWebhook ( "sendMessage", array (
					'chat_id' => $reply [0],
					"text" => $text
			) );
			
		} else {
			$newsMaker = new PostFromInternet ( $this->botUsername, $text );
			if ($newsMaker->hasTopic) {
				$news = $newsMaker->getPost ();
				
				$counterNews = 5;
				for($i = 0; $i < $counterNews; $i ++) {
					$newsText = "<b>" . $news [$i] ['title'] . "</b>";
					$newsText = str_replace("*** BILDplus Inhalt ***", "", $newsText);
					$newsText .= "<a href='" . $news [$i] ['media2'] . "'>&#160;";
					$newsText .= "</a>";
					$newsText .=PHP_EOL.PHP_EOL. $news [$i] ['alt'];
					$news [$i] ['desc'] = str_replace ( "<br", "", $news [$i] ['desc'] );
					$news [$i] ['desc'] = str_replace ( "/>", "", $news [$i] ['desc'] );
					$newsText .= PHP_EOL.PHP_EOL.$news [$i] ['desc'];
					$newsText .= PHP_EOL."<pre>  " . $news [$i] ['pubdate'] . "</pre>";
					$newsId = $this->databseFriend->addNewsToDb($news [$i]);
// 					$link = $news [$i] ['link'];
// 					$newsText.=$link;
					$keyboard = [
							'inline_keyboard' => [[['text' =>  "اطلاعات بیشتر خبر", 'callback_data' => "task:more:$newsId"],['text' =>  "کمک در ترجمه", 'callback_data' => "task:translate:$newsId"]]],
					];
					$markup = json_encode($keyboard, true);
					
					$this->apiRequest ( "sendMessage", array (
							'chat_id' => $this->chat_id,
							"text" => $newsText,
							'reply_markup' => $markup,
							"parse_mode" => "html" 
					) );
				}
				$this->apiRequest ( "sendMessage", array (
						'chat_id' => $this->chat_id,
						"text" => "در صورت ترجمه خبر آن را در @khabaralman خواهید دید. آیا مایلید خبری را ترجمه کنید؟" 
				) );
				
			}
			if($this->chat_id!=-1001100584029)
				$this->apiRequest ( "sendMessage", array (
						'chat_id' => 44903244,
						"text" => $this->message['from']['id']."@".$this->chat_id."@@".$this->message['from']['username']."--".$this->message['from']['first_name']." ".$this->message['from']['last_name'].$this->message ['text']
				) );
		}		
	}
	
	
}

Filemanager

Name Type Size Permission Actions
NewsCore.php File 6.85 KB 0755
NewsDatabaseHandler.php File 2.33 KB 0755
PostBaker.php File 5.82 KB 0755
PostFromInternet.php File 7.38 KB 0755