404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.188.103.42: ~ $
<?php
// include "Enum.php";

class TranslateService extends MessageProcessor
{
	public $translated;
	public $hasSoundex;
	public $lookForSound;
	public $contributedTranslation;
	public $db;
	public $cachtedUser;
	public $keyboard;
	public $word;
	public $dictionaryDbHandler;
	public $underRepair = false;
	public $isAdvertisementTime = true;
	public $repairementMessage = "ربات لغت نامه در حال تعمیر است";
	public $adsManager;
	public $catchedUser;
	public $debugsManager;
	private $patreonService;

	public $intentService;
	public $searchService;
	public $dictionary;
	public $accessManager;
	public $inviteService;
	public $usersManager;
	public $contributionService;
	public $callbackService;
	public $ttsService;
	public $buttonService;
	public $learn;
	public $evaluationSystem;
	private $youtubeLinks = [];

	protected static $variable;

	function __construct($botUsername, $botToken, $webhookUrl)
	{
		parent::__construct($botUsername, $botToken, $webhookUrl, "signed", 44903244);
		$this->translated = false;
		$this->hasSoundex = false;
		$this->contributedTranslation = false;
		$this->translated = true;
		$this->adminId = 44903244;
		$this->lookForSound = TRUE;
		$this->db = new DictionaryDatabaseHandler($this);
		$this->adsManager = new AdsManager($this);
		$this->keyboard = new KeyboardMenu($this);
		
		$this->debugsManager = new DebugsManager();
		$this->intentService = new IntentService($this);
		$this->searchService = new SearchService($this);
		$this->accessManager = new AccessManager($this);
		$this->inviteService = new InviteService($this);


		$this->usersManager = new UsersManager($this);
		$this->contributionService = new ContributionService($this);
		$this->ttsService = new TTSService($this);
		$this->buttonService = new ButtonService($this);
		$this->patreonService = new PatreonService($this);

		
		$this->init();
		$this->callbackService = new CallbackService($this);
		$this->dictionary = &$this->db;
	}
	protected function init()
	{
		$this->sendMessageLog("inited but why?");
		$this->evaluationSystem = new EvaluationSystem($this);
		$this->learn = new LearnSystem($this, $this->callback_data);

	}
	public function getDB()
	{
		return $this->db;
	}
	public function getButtonService(): ButtonService
	{
		return $this->buttonService;
	}
	public function getLearnSystem(): LearnSystem
	{
		return $this->learn;
	}
	public function getPatreonService(): PatreonService
	{
		return $this->patreonService;
	}
	public function setPatreonService(PatreonService $patreonService): TranslateService
	{
		$this->patreonService = $patreonService;
		return $this;
	}
	function getEvaluationSystem(): EvaluationSystem
	{
		return $this->evaluationSystem;
	}

	public function getSearchService(): SearchService
	{
		return $this->searchService;
	}

	public function getTTS(): TTSService
	{
		return $this->ttsService;
	}

	public function getDebugsManager()
	{
		return $this->debugsManager;
	}
	public function getInviteService(): InviteService
	{
		return $this->inviteService;
	}
	public function getIntentService(): IntentService
	{
		return $this->intentService;
	}
	public function getAccessManager(): AccessManager
	{
		return $this->accessManager;
	}
	public function addInRepairmentStack($userID, $word)
	{
		$this->getDB()->addInRepairmentStack($userID, $word);
	}
	public function setRepairementMessage($message)
	{
		$this->repairementMessage = $message;
	}
	public function setUnderRepair($enable)
	{
		$this->underRepair = $enable;
	}

	public function isUnderRepair()
	{
		return $this->underRepair;
	}
	public function processCallback($update)
	{
		$this->callbackService->findRequestHandler($update);
		$this->getDB()->disconnect();
	}

	public function getTranslatedText($word)
	{
		return $word;
	}

	public function makeTranslationTextMessage()
	{
		$translated = "";
		if (!is_array($this->getDB()->wordArrayResult) || !$this->getDB()->translated) {
			return $translated = "keine Ahnung 😭";
		}
		foreach ($this->getDB()->wordArrayResult as $word) {
			if ($word['word']) {
				$translated .= $this->styleTranslation($word);
			}
			if($word['youtube_link']){
				if(!in_array($word['youtube_link'], $this->youtubeLinks)){	
					$this->youtubeLinks[] = $word['youtube_link']; 
				}
			}
		}
		return $translated . " 😊" . PHP_EOL . " @TranslateGerman_bot";
	}

	public function styleTranslation($word)
	{
		throw new Exception("abstract styling");
	}

	public function getLang($word)
	{
		return $this->isPersianLanguage($word) ? "FA" : "DE";
	}

	public function processInlineQuery($update)
	{
		$this->intentService->findInlineIntent($update);
	}

	public function getAdsManager(): AdsManager
	{
		return $this->adsManager;
	}

	public function getUser()
	{
		if($this->catchedUser)
			return $this->catchedUser;
		$this->catchedUser =  $this->db->getUser($this->chat_id);
		return $this->catchedUser;
	}

	public function handleTranslate()
	{
		if (!$this->accessManager->isAllowedToTranslate())
			return false;

		$translatedTextMessage = $this->getTranslatedText($this->word);
		$markup = $this->getMarkedupButtons();
		$this->sendMarkedupMessageWeb($translatedTextMessage, $markup);
		for( $i =0; $i < count($this->youtubeLinks); $i++){
			$this->sendYoutubeLink($this->youtubeLinks[$i]);
		}
	}
	public function getMarkedupButtons()
	{
		$this->addButtons();
		$markup = $this->getButtonService()->createMarkUpButtons();
		return $markup;
	}
	public function addButtons()
	{
	}

	public function processPhoto($update)
	{
		parent::processPhoto($update);
		$size = sizeof($this->message['photo']);
		$fileId = $this->message['photo'][$size - 1]['file_id'];
		$markupButtons = $this->getButtonService()->getImageButtons();
		$this->sendPhotoMarkedUp($fileId,$this->chat_id, $markupButtons);
	}

	public function processVoice($update)
	{
		parent::processVoice($update);
		$fileId = $this->message['voice']['file_id'];
		$markupButtons = $this->getButtonService()->getVoiceButton();
		$this->sendVoiceMarkedUp($fileId,$this->chat_id, $markupButtons);
	}

	public function processText()
	{
		$text = $this->message['text'];
		// $supportMsg = "ربات لغتنامه در حال ارتقا هست. از اینکه فعلا نمی تونم پاسخ بدم عذر می خوام. تا ساعاتی دیگه درست می شه";
		
		// $this->sendMessage($supportMsg,$this->chat_id);
		// return false;
		$this->usersManager->insertUser();
		if ($this->keyboard->listen())
		return true;
		if ($this->getLearnSystem()->listen())
		return true;
		
		$this->message['text'] = $this->cleanWord($this->message['text']);
		$this->word = $this->message['text'];
		
		$intents  = $this->getIntentService()->findIntents($text);
		foreach($intents as $intent){
			if($intent->getIntentID() == 100) {
				$this->handleTranslate($text);
			}
			else if (isset($intent) && $intent->getIntentID() != 100) {
				$intent->act();
			}		
			$this->getDB()->insertUserActivity($this->message['from']['id'], $text, $intent->getIntentID());
		}
		$this->getDB()->disconnect();
	}

	public function cleanWord($word)
	{
		if (strpos(strtolower($word), "die ") === 0 || strpos(strtolower($word), "der ") === 0 || strpos(strtolower($word), "das ") === 0) {
			$word = substr($word, 4);
		}
		return $word;
	}
}

Filemanager

Name Type Size Permission Actions
german Folder 0755
swedish Folder 0755
TranslateEnglish.php File 20.95 KB 0644
TranslateService.php File 7.1 KB 0644