<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of DictCC
*
* @author len
*/
class DictCC {
//put your code here
public $TG;
function __construct(TranslateService $TranslateService) {
$this->TG = $TranslateService;
}
function checkWord($word){
$word = str_replace(" ", "+", $word);
$url = "https://m.dict.cc/deen/?s=".$word;
// $url = "https://m.dict.cc/deen/?s=zulassungsstelle";
$contents = file_get_contents($url);
// $regex = '<div id="transview">([\s\S]*?)<div class="sugviewspacer">'
// $regex = '#\<div id=\"transview\"\>([\s\S]*?)\<div class\=\"sugviewspacer\">#g';
$regex = '/\<div id=\"transview\"\>([\s\S]*?)\<div class=\"sugviewspacer\">/';
preg_match_all($regex, $contents, $matches);
// print_r($matches);
$out = strip_tags($matches[1][0]);
$out = str_replace("(adsbygoogle = window.adsbygoogle || []).push({});", "", $out);
$out = str_replace(" ", " ", $out);
$out = str_replace("\n", " ", $out);
$out = str_replace(" \n", " ", $out);
$out = str_replace(" ", "\n\n", $out);
$out = substr($out, 0, 700);
$answerArray = [
['text'=>'حذفم کن', 'id'=>EnumOrder::DELETE_ME]
];
$this->TG->askUserMultipleChoiceQuestion($out,$answerArray,$this->TG->chat_id,$this->TG->message_id);
}
}