<?php
class ContributionService extends BaseSerevice {
public function sendContributionMessageg($userActivityId, $word){
$userArray = $this->getTG()->getDB()->getSomeUsers($this->chat_id);
foreach ($userArray as $user){
if(isset($user['userid'])){
$this->getTG()->getDB()->setUserStep($user['userid'], EnumSteps::USER_ASKED_FOR_CONTRIBUTION);
// $this->suggestContribution($userActivityId, $user['userid'], $word);
// $this->suggestContribution($userActivityId, $this->adminId, $word);
}
}
}
public function getTranslationFromContributions($word, $noHtmlTag=False){
$text ="";
$transArray = $this->getTG()->getDB()->lookForWordInContributionTable($word);
$transArray2 = $this->getTG()->getDB()->lookForRelatedWordInContributionTable($word);
if(is_array($transArray) && !empty($transArray[0])){
$this->getTG()->contributedTranslation = true;
$this->getTG()->translated = true;
$this->getTG()->lookForSound = FALSE;
}
if(is_array($transArray2) && !empty($transArray2[0])){
$this->getTG()->translated = true;
$this->getTG()->lookForSound = FALSE;
}
foreach ($transArray as $word){
if(!empty($word))
$text .= $word['word'].": ".$word['translation'].PHP_EOL;
}
foreach ($transArray2 as $word2){
// $contId = $word['id'];
$related = $word2['relatedWord'];
$contId = $word2['id'];
if(!empty($related))
$answerArray [] = ['text'=>$related, 'id'=>"get:$contId"];
}
if(is_array($transArray2)){
$this->getTG()->askUserMultipleChoiceQuestion("کدوم کلمه منظورت بود؟", $answerArray, $this->chat_id);
}
if($this->getTG()->contributedTranslation)
return $text.PHP_EOL."☺️".PHP_EOL."@TranslateGerman_bot";
// else
// return "یک کلمه انتخاب کن";
}
}
?>