Commit ae1e736f authored by Kulya's avatar Kulya 😊

Fix warn in actionfile

parent 0bdf9531
...@@ -629,7 +629,7 @@ class AloVoiceActions ...@@ -629,7 +629,7 @@ class AloVoiceActions
} }
$keyVal = explode(':', trim($line)); $keyVal = explode(':', trim($line));
$tag = trim($keyVal[0]); $tag = trim($keyVal[0]);
$value = trim($keyVal[1]," \t\n\r\0\x0B\""); $value = (!empty($keyVal[1])) ? trim($keyVal[1]," \t\n\r\0\x0B\"") : "";
if(!empty($keyVal[2])) { $value = $value.' '.trim($keyVal[2]," \t\n\r\0\x0B\""); } if(!empty($keyVal[2])) { $value = $value.' '.trim($keyVal[2]," \t\n\r\0\x0B\""); }
if (!$tag) continue; if (!$tag) continue;
......
...@@ -242,15 +242,15 @@ class AloVoiceConnector ...@@ -242,15 +242,15 @@ class AloVoiceConnector
return $this->returnRes($resAction); return $this->returnRes($resAction);
} }
$this->TG = new \TGA\ATelegram(); // $this->TG = new \TGA\ATelegram();
$tgla = $this->TG->doTgMethod($_REQUEST); // $tgla = $this->TG->doTgMethod($_REQUEST);
$this->eLog($tgla,"------ ATelegram: RES:"); // $this->eLog($tgla,"------ ATelegram: RES:");
if(!empty($tgla)){ // if(!empty($tgla)){
if( !empty($tgla["action"]) ){ // if( !empty($tgla["action"]) ){
$alvRest->doMethod($tgla["action"]); // $alvRest->doMethod($tgla["action"]);
} // }
return $this->returnRes($tgla); // return $this->returnRes($tgla);
} // }
$bxEvent = new BitrixEvents($this->configs); $bxEvent = new BitrixEvents($this->configs);
if(!empty($bxEventRes = $bxEvent->runEvents())){ if(!empty($bxEventRes = $bxEvent->runEvents())){
...@@ -2396,6 +2396,9 @@ CFU='; ...@@ -2396,6 +2396,9 @@ CFU=';
} }
if(empty($outBxCallId)){ if(empty($outBxCallId)){
if(strlen($queryData)==9){
$queryData = "+998".$queryData;
}
$bxRes = BxRest::call("telephony.externalcall.register",$queryData); $bxRes = BxRest::call("telephony.externalcall.register",$queryData);
self::eLog($bxRes,"--== startCall RES:"); self::eLog($bxRes,"--== startCall RES:");
} else { } else {
...@@ -3295,24 +3298,31 @@ CFU='; ...@@ -3295,24 +3298,31 @@ CFU=';
return false; return false;
} }
public function didox_inn($inn=false){ public function didox_inn($inn=false,$info=false){
$frominn = '303903621'; $frominn = '303903621';
$didoxTokenFile = __DIR__.'/didox.json'; $didoxTokenFile = __DIR__.'/didox.json';
$didoxToken = false; $didoxToken = false;
$jsDidoxToken = file_get_contents($didoxTokenFile); $jsDidoxToken = file_get_contents($didoxTokenFile);
$timerz = 36000; $timerz = 3600;
self::eLog("Test DiDox INN TokenCheck time[".time()."] JS:".$jsDidoxToken);
if(!empty($jsDidoxToken)){ if(!empty($jsDidoxToken)){
$arDdxToken = json_decode($jsDidoxToken,true); $arDdxToken = json_decode($jsDidoxToken,true);
if(!empty($arDdxToken["time"]) && !empty($arDdxToken["token"])){ if(!empty($arDdxToken["time"]) && !empty($arDdxToken["token"])){
$ddxrz = time()-$arDdxToken["time"]; $ddxrz = time() - $arDdxToken["time"];
self::eLog("Test DiDox INN TokenCheck Razn[".$ddxrz."]");
if($ddxrz<$timerz){ if($ddxrz<$timerz){
$didoxToken = $arDdxToken["token"]; $didoxToken = $arDdxToken["token"];
} }
} }
} }
self::eLog("Test DiDox INN TokenCheck:".$didoxToken);
if(empty($didoxToken)){ if(empty($didoxToken)){
$ddxRes = self::didoxrequest(false,"user/".$frominn."/token",["password"=>"mteamgfhjkm"]); $ddxRes = self::didoxrequest(false,"user/".$frominn."/token",["password"=>"mteamgfhjkm"]);
self::eLog("Test DiDox INN TokenCheck REQ RES:".$ddxRes);
if(!empty($ddxRes) && strlen($ddxRes)>20){ if(!empty($ddxRes) && strlen($ddxRes)>20){
if(file_put_contents($didoxTokenFile,json_encode(["time"=>time(),"token"=>$ddxRes]))){ if(file_put_contents($didoxTokenFile,json_encode(["time"=>time(),"token"=>$ddxRes]))){
$didoxToken = $ddxRes; $didoxToken = $ddxRes;
...@@ -3324,19 +3334,32 @@ CFU='; ...@@ -3324,19 +3334,32 @@ CFU=';
if(!empty($didoxToken) && !empty($inn)){ if(!empty($didoxToken) && !empty($inn)){
$ddxInnRes = self::didoxrequest($didoxToken,"info/".$inn); $ddxInnRes = self::didoxrequest($didoxToken,"info/".$inn);
$arInnRes = json_decode($ddxInnRes,true); // $arInnRes = json_decode($ddxInnRes,true);
if(!empty($arInnRes)){ // if(!empty($arInnRes)){
return $arInnRes; // return $arInnRes;
// }
}
elseif(!empty($info)){
if($info=="banks"){
$ddxInnRes = self::didoxrequest($didoxToken,"https://api.didox.uz/v1/banks/all");
}
elseif($info=="regions"){
$ddxInnRes = self::didoxrequest($didoxToken,"https://api.didox.uz/v1/regions/all");
} }
} }
return false; return (!empty($ddxInnRes)) ? $ddxInnRes : false;
} }
public function didoxrequest($t,$m,$d=false){ public function didoxrequest($t,$m,$d=false,$p=false){
if(empty($m)){ return ""; } if(empty($m)){ return ""; }
//https://api.goodsign.biz/waltz/goodsign/0.0.1/user/303903621/token //https://api.goodsign.biz/waltz/goodsign/0.0.1/user/303903621/token
if(substr($m,0,5)=="https"){
$urlrest = $m;
}
else {
$urlrest = 'https://api.goodsign.biz/waltz/goodsign/0.0.1/'.$m; $urlrest = 'https://api.goodsign.biz/waltz/goodsign/0.0.1/'.$m;
}
// $urlrest = 'https://api.goodsign.biz/waltz/goodsign/0.0.1/info/'.$inn; // $urlrest = 'https://api.goodsign.biz/waltz/goodsign/0.0.1/info/'.$inn;
$curl = curl_init(); $curl = curl_init();
...@@ -3377,7 +3400,7 @@ CFU='; ...@@ -3377,7 +3400,7 @@ CFU=';
return $response; return $response;
// return json_decode($response,true); // return json_decode($response,true);
} }
//UF_CRM_1609777763
public function nn($number,$nplus=false) { public function nn($number,$nplus=false) {
// self::eLog($number,"Number test 1"); // self::eLog($number,"Number test 1");
$number = preg_replace("/[^0-9]/", '', $number); $number = preg_replace("/[^0-9]/", '', $number);
...@@ -3395,6 +3418,59 @@ CFU='; ...@@ -3395,6 +3418,59 @@ CFU=';
return ($nplus) ? substr($number,1) : $number; return ($nplus) ? substr($number,1) : $number;
} }
public function num2str($num) {
$nul='ноль';
$ten=array(
array('','один','два','три','четыре','пять','шесть','семь', 'восемь','девять'),
array('','одна','две','три','четыре','пять','шесть','семь', 'восемь','девять'),
);
$a20=array('десять','одиннадцать','двенадцать','тринадцать','четырнадцать' ,'пятнадцать','шестнадцать','семнадцать','восемнадцать','девятнадцать');
$tens=array(2=>'двадцать','тридцать','сорок','пятьдесят','шестьдесят','семьдесят' ,'восемьдесят','девяносто');
$hundred=array('','сто','двести','триста','четыреста','пятьсот','шестьсот', 'семьсот','восемьсот','девятьсот');
$unit=array( // Units
array('копейка' ,'копейки' ,'копеек', 1),
array('' ,'' ,'' ,0),
// array('рубль' ,'рубля' ,'рублей' ,0),
array('тысяча' ,'тысячи' ,'тысяч' ,1),
array('миллион' ,'миллиона','миллионов' ,0),
array('миллиард','милиарда','миллиардов',0),
);
//
list($rub,$kop) = explode('.',sprintf("%015.2f", floatval($num)));
$out = array();
if (intval($rub)>0) {
foreach(str_split($rub,3) as $uk=>$v) { // by 3 symbols
if (!intval($v)) continue;
$uk = sizeof($unit)-$uk-1; // unit key
$gender = $unit[$uk][3];
list($i1,$i2,$i3) = array_map('intval',str_split($v,1));
// mega-logic
$out[] = $hundred[$i1]; # 1xx-9xx
if ($i2>1) $out[]= $tens[$i2].' '.$ten[$gender][$i3]; # 20-99
else $out[]= $i2>0 ? $a20[$i3] : $ten[$gender][$i3]; # 10-19 | 1-9
// units without rub & kop
if ($uk>1) $out[]= self::morph($v,$unit[$uk][0],$unit[$uk][1],$unit[$uk][2]);
} //foreach
}
else $out[] = $nul;
$out[] = self::morph(intval($rub), $unit[1][0],$unit[1][1],$unit[1][2]); // rub
// $out[] = $kop.' '.self::morph($kop,$unit[0][0],$unit[0][1],$unit[0][2]); // kop
return trim(preg_replace('/ {2,}/', ' ', join(' ',$out)));
}
/**
* Склоняем словоформу
* @ author runcore
*/
public function morph($n, $f1, $f2, $f5) {
$n = abs(intval($n)) % 100;
if ($n>10 && $n<20) return $f5;
$n = $n % 10;
if ($n>1 && $n<5) return $f2;
if ($n==1) return $f1;
return $f5;
}
public function statAPI($m,$p){ public function statAPI($m,$p){
if(empty($m)){ return false; } if(empty($m)){ return false; }
......
...@@ -143,7 +143,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -143,7 +143,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$msgFrom = $eventKeys["from"]; $msgFrom = $eventKeys["from"];
$crmEntitySearchResult = BxRest::call("telephony.externalCall.searchCrmEntities",array( $crmEntitySearchResult = BxRest::call("telephony.externalCall.searchCrmEntities",array(
'PHONE_NUMBER' => $msgFrom, 'PHONE_NUMBER' => ALVC::nn($msgFrom),
)); ));
self::eLog($crmEntitySearchResult,"--== SMS searchCrmEntities RESULT:",true); self::eLog($crmEntitySearchResult,"--== SMS searchCrmEntities RESULT:",true);
...@@ -349,7 +349,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -349,7 +349,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
} }
} }
$connLineNum = (!empty($eventKeys["connectedlinenum"])) ? substr($eventKeys["connectedlinenum"],-9) : false; $connLineNum = (!empty($eventKeys["connectedlinenum"])) ? ALVC::nn($eventKeys["connectedlinenum"]) : false;
if($callRegisterParams["TYPE"]==1){ if($callRegisterParams["TYPE"]==1){
$callRegisterParams["USER_PHONE_INNER"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]; $callRegisterParams["USER_PHONE_INNER"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"];
...@@ -360,17 +360,17 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -360,17 +360,17 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
elseif( (!empty($bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"])) && (!empty($this->bxusers[$bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]])) ){ elseif( (!empty($bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"])) && (!empty($this->bxusers[$bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]])) ){
$callRegisterParams["USER_PHONE_INNER"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]; $callRegisterParams["USER_PHONE_INNER"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"];
$callRegisterParams["USER_ID"] = $this->bxusers[$bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]]["ID"]; $callRegisterParams["USER_ID"] = $this->bxusers[$bxchannels[$eventKeys["linkedid"]]["BX24_CALLERID"]]["ID"];
$callRegisterParams["PHONE_NUMBER"] = (is_numeric($connLineNum)) ? $connLineNum : substr($eventKeys["destexten"],-9); $callRegisterParams["PHONE_NUMBER"] = (is_numeric($connLineNum)) ? $connLineNum : ALVC::nn($eventKeys["destexten"]);
$callRegisterParams["DESC"] = $eventKeys["destchannel"]; $callRegisterParams["DESC"] = $eventKeys["destchannel"];
} }
elseif( !empty($this->bxusers[$eventKeys["destexten"]]) ){ elseif( !empty($this->bxusers[$eventKeys["destexten"]]) ){
$callRegisterParams["USER_PHONE_INNER"] = $eventKeys["destexten"]; $callRegisterParams["USER_PHONE_INNER"] = $eventKeys["destexten"];
$callRegisterParams["USER_ID"] = $this->bxusers[$eventKeys["destexten"]]["ID"]; $callRegisterParams["USER_ID"] = $this->bxusers[$eventKeys["destexten"]]["ID"];
$callRegisterParams["PHONE_NUMBER"] = substr($eventKeys["calleridnum"],-9); $callRegisterParams["PHONE_NUMBER"] = ALVC::nn($eventKeys["calleridnum"]);
$callRegisterParams["DESC"] = $eventKeys["calleridname"]; $callRegisterParams["DESC"] = $eventKeys["calleridname"];
} }
else { else {
$callRegisterParams["PHONE_NUMBER"] = substr($eventKeys["calleridnum"],-9); $callRegisterParams["PHONE_NUMBER"] = ALVC::nn($eventKeys["calleridnum"]);
} }
$searchNumber = $callRegisterParams["PHONE_NUMBER"]; $searchNumber = $callRegisterParams["PHONE_NUMBER"];
...@@ -485,7 +485,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -485,7 +485,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$stParams = [ $stParams = [
'TYPE' => $calltype, 'TYPE' => $calltype,
'USER_PHONE_INNER' => $phoneInner, 'USER_PHONE_INNER' => $phoneInner,
'PHONE_NUMBER' => $eventKeys["destconnectedlinenum"] 'PHONE_NUMBER' => ALVC::nn($eventKeys["destconnectedlinenum"])
]; ];
$registerResult = ALVC::startCall($stParams,$bxchannels[$linkedID]); $registerResult = ALVC::startCall($stParams,$bxchannels[$linkedID]);
...@@ -694,8 +694,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -694,8 +694,7 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
); );
if( !empty($chVars["REALCALLERIDNUM"]) ){ if( !empty($chVars["REALCALLERIDNUM"]) ){
$realCallerNum = preg_replace("/[^0-9]/", '', $chVars["REALCALLERIDNUM"]); $realCallerNum = ALVC::nn($chVars["REALCALLERIDNUM"]);
$realCallerNum = substr($realCallerNum,-9);
$regParams['PHONE_NUMBER'] = (!empty($realCallerNum)) ? $realCallerNum : ''; $regParams['PHONE_NUMBER'] = (!empty($realCallerNum)) ? $realCallerNum : '';
if(empty($regParams['PHONE_NUMBER'])){ $regParams['PHONE_NUMBER'] = (!empty($chVars["BX24_CALLERID"])) ? $chVars["BX24_CALLERID"] : '1000002'; } if(empty($regParams['PHONE_NUMBER'])){ $regParams['PHONE_NUMBER'] = (!empty($chVars["BX24_CALLERID"])) ? $chVars["BX24_CALLERID"] : '1000002'; }
......
...@@ -1937,6 +1937,36 @@ function(result){ ...@@ -1937,6 +1937,36 @@ function(result){
'status'=>'off', 'status'=>'off',
)]; )];
$res['nextintegration'] = 'status_dealupdate';
$res['rescheck'] = $arResults;
return $res;
}
private function status_dealupdate($r=false) {
$arResults = BxRest::call('event.get');
$integrations = [];
if(!empty($arResults["result"])){
foreach($arResults["result"] as $itg){
if( $itg["event"] == "ONCRMDEALUPDATE" ){
if( $itg["handler"] == $this->config["alovoice_host"] ){
$integrations[] = array(
'code'=>'crmdealupdate',
'title'=>'Обновления сделок',
'status'=>'on',
);
}
}
}
}
$res['lines'] = (!empty($integrations)) ? $integrations : [array(
'code'=>'crmdealupdate',
'title'=>'Обновления сделок',
'status'=>'off',
)];
$res['nextintegration'] = 'status_alvcrmmenus'; $res['nextintegration'] = 'status_alvcrmmenus';
$res['rescheck'] = $arResults; $res['rescheck'] = $arResults;
...@@ -2403,6 +2433,13 @@ function(result){ ...@@ -2403,6 +2433,13 @@ function(result){
]); ]);
return array( 'do' => $doResult, 'result' => 'success'); return array( 'do' => $doResult, 'result' => 'success');
} }
if($r["code"]=='crmdealupdate'){
$doResult = BxRest::call('event.bind',[
'event'=>'ONCRMDEALUPDATE',
'handler'=>$this->config["alovoice_host"],
]);
return array( 'do' => $doResult, 'result' => 'success');
}
if($r["code"]=='tgservice'){ if($r["code"]=='tgservice'){
$arResults = BxRest::call('imconnector.unregister',[ 'ID' => 'alotg' ]); $arResults = BxRest::call('imconnector.unregister',[ 'ID' => 'alotg' ]);
...@@ -2650,6 +2687,22 @@ function(result){ ...@@ -2650,6 +2687,22 @@ function(result){
return array( 'do' => $doResult, 'result' => 'success'); return array( 'do' => $doResult, 'result' => 'success');
} }
if($r["code"]=='crmdealupdate'){
$doResult = BxRest::call('event.unbind',[
'event'=>'ONCRMDEALUPDATE',
'handler'=>$this->config["alovoice_host"],
]);
return array( 'do' => $doResult, 'result' => 'success');
}
if($r["code"]=='contactupdate'){
$doResult = BxRest::call('event.unbind',[
'event'=>'ONCRMCONTACTUPDATE',
'handler'=>$this->config["alovoice_host"],
]);
return array( 'do' => $doResult, 'result' => 'success');
}
if($r["code"]=='leadupdateevent'){ if($r["code"]=='leadupdateevent'){
$doResult = BxRest::call('event.unbind',[ $doResult = BxRest::call('event.unbind',[
'event'=>'ONCRMLEADUPDATE', 'event'=>'ONCRMLEADUPDATE',
......
...@@ -1298,6 +1298,30 @@ class BitrixEvents ...@@ -1298,6 +1298,30 @@ class BitrixEvents
public function oncrmdealupdate() { public function oncrmdealupdate() {
ALVC::eLog($this->bxData,"------ Events.php :: oncrm DEAL UPDATE:"); ALVC::eLog($this->bxData,"------ Events.php :: oncrm DEAL UPDATE:");
$dealId = $this->bxData["FIELDS"]["ID"];
$resDeal = BxRest::call( 'crm.deal.get', array("id"=>$dealId) );
ALVC::eLog($resDeal,"------ Events.php :: Deal GET Result: ----------");
if(!empty($resDeal["result"]["ID"])){
$arDeal = $resDeal["result"];
ALVC::eLog($arDeal["OPPORTUNITY"],"------ Events.php :: Deal GET Result: ----------");
if(empty($arDeal["OPPORTUNITY"]) && !empty($arDeal["UF_CRM_1609777763"])){
$oprtnty = round($arDeal["OPPORTUNITY"]);
$oprtntyTxt = ALVC::num2str($oprtnty);
$resDealSave = BxRest::call( 'crm.deal.update', array("id"=>$dealId, "fields"=>["UF_CRM_1609777763"=>$oprtntyTxt]) );
ALVC::eLog($resDealSave,"------ Events.php :: Deal Update Oport TXT: ".$oprtntyTxt);
}
if(!empty($arDeal["OPPORTUNITY"])){ //&& empty($arDeal["UF_CRM_1609777763"])
$oprtnty = round($arDeal["OPPORTUNITY"]);
$oprtntyTxt = ALVC::num2str($oprtnty);
$resDealSave = BxRest::call( 'crm.deal.update', array("id"=>$dealId, "fields"=>["UF_CRM_1609777763"=>$oprtntyTxt]) );
ALVC::eLog($resDealSave,"------ Events.php :: Deal Update Oport TXT: ".$oprtntyTxt);
}
}
} }
public function crm_deal_activity_timeline_menu__() { public function crm_deal_activity_timeline_menu__() {
// ALVC::eLog($this->bxData,"------ Events.php :: oncrm DEAL Activity MENU:"); // ALVC::eLog($this->bxData,"------ Events.php :: oncrm DEAL Activity MENU:");
...@@ -1317,6 +1341,27 @@ class BitrixEvents ...@@ -1317,6 +1341,27 @@ class BitrixEvents
public function oncrmleadupdate() { public function oncrmleadupdate() {
$leadID = $this->bxData["FIELDS"]["ID"]; $leadID = $this->bxData["FIELDS"]["ID"];
$resLead = BxRest::call( 'crm.lead.get', array("id"=>$leadID) );
// ALVC::eLog($resLead,"------ Events.php :: lead GET Result: ----------");
if(!empty($resLead["result"]["ID"])){
$arLead = $resLead["result"];
ALVC::eLog($arLead["OPPORTUNITY"],"------ Events.php :: lead GET Result: ----------");
if(!empty($arLead["OPPORTUNITY"])){ //&& empty($arLead["UF_CRM_1619575012878"])
$oprtnty = round($arLead["OPPORTUNITY"]);
$oprtntyTxt = ALVC::num2str($oprtnty);
$resDealSave = BxRest::call( 'crm.lead.update', array("id"=>$leadID, "fields"=>["UF_CRM_1619575012878"=>$oprtntyTxt]) );
ALVC::eLog($resDealSave,"------ Events.php :: lead Update Oport TXT: ".$oprtntyTxt);
}
if(empty($arLead["OPPORTUNITY"]) && !empty($arLead["UF_CRM_1619575012878"])){
$resDealSave = BxRest::call( 'crm.lead.update', array("id"=>$leadID, "fields"=>["UF_CRM_1619575012878"=>""]) );
}
}
// $resLead = BxRest::call( 'crm.lead.get', array("id"=>$leadID) ); // $resLead = BxRest::call( 'crm.lead.get', array("id"=>$leadID) );
// ALVC::eLog($resLead,"------ Events.php :: Deal GET Result: ----------"); // ALVC::eLog($resLead,"------ Events.php :: Deal GET Result: ----------");
...@@ -1338,7 +1383,7 @@ class BitrixEvents ...@@ -1338,7 +1383,7 @@ class BitrixEvents
public function oncrmleadadd() { public function oncrmleadadd() {
$leadID = $this->bxData["FIELDS"]["ID"]; $leadID = $this->bxData["FIELDS"]["ID"];
$resLead = BxRest::call( 'crm.lead.get', array("id"=>$leadID) ); $resLead = BxRest::call( 'crm.lead.get', array("id"=>$leadID) );
ALVC::eLog($resLead,"------ Events.php :: Deal GET Result: ----------"); // ALVC::eLog($resLead,"------ Events.php :: Deal GET Result: ----------");
if(!empty($resLead["result"]["ID"])){ if(!empty($resLead["result"]["ID"])){
$tgres = ALVC::checkTgContact($resLead["result"]); $tgres = ALVC::checkTgContact($resLead["result"]);
......
...@@ -55,6 +55,7 @@ class ATelegram { ...@@ -55,6 +55,7 @@ class ATelegram {
} }
public function get_contact($phone){ public function get_contact($phone){
return false;
$this->tLog($phone, "-- get_contact BEGIn CONTACT SEARCH:"); $this->tLog($phone, "-- get_contact BEGIn CONTACT SEARCH:");
if( (empty($this->TGM)) || (empty($this->tg_sender_default)) ){ if( (empty($this->TGM)) || (empty($this->tg_sender_default)) ){
$this->tLog($phone, "-- get_contact NO Telegram Connect:"); $this->tLog($phone, "-- get_contact NO Telegram Connect:");
...@@ -118,6 +119,7 @@ class ATelegram { ...@@ -118,6 +119,7 @@ class ATelegram {
} }
public function contactsUpdate(){ public function contactsUpdate(){
return true;
if( (empty($this->TGM)) || (empty($this->tg_sender_default)) ){ if( (empty($this->TGM)) || (empty($this->tg_sender_default)) ){
return false; return false;
} }
...@@ -153,6 +155,7 @@ class ATelegram { ...@@ -153,6 +155,7 @@ class ATelegram {
public function doTgMethod($prms){ public function doTgMethod($prms){
return true;
/*if (!empty($prms['event']) && $prms['event'] == 'ONIMCONNECTORMESSAGEADD' && !empty($prms['data']['CONNECTOR']) && $prms['data']['CONNECTOR'] == $this->code && !empty($prms['data']['MESSAGES'])){ /*if (!empty($prms['event']) && $prms['event'] == 'ONIMCONNECTORMESSAGEADD' && !empty($prms['data']['CONNECTOR']) && $prms['data']['CONNECTOR'] == $this->code && !empty($prms['data']['MESSAGES'])){
return $this->on_imconnectormessageadd($prms); return $this->on_imconnectormessageadd($prms);
...@@ -208,6 +211,7 @@ class ATelegram { ...@@ -208,6 +211,7 @@ class ATelegram {
} }
public function incom_tgmessage($p=false){ public function incom_tgmessage($p=false){
return true;
$this->tLog("-------------------==ATG incom_tgmessage ==----------------"); $this->tLog("-------------------==ATG incom_tgmessage ==----------------");
/* /*
$action = [ $action = [
...@@ -467,24 +471,15 @@ class ATelegram { ...@@ -467,24 +471,15 @@ class ATelegram {
} }
} }
} }
/*
{id: "$01000000182773071d3a41e62f1c9b0b", peer_type: "user", peer_id: 124987160,…}
first_name: "КУЛДАШ Шухратович"
flags: 196609
id: "$01000000182773071d3a41e62f1c9b0b"
last_name: "НАВРУЗОВ"
peer_id: 124987160
peer_type: "user"
phone: "998977076909"
print_name: "КУЛДАШ_Шухратович_НАВРУЗОВ"
username: "kuldash"
when: "2021-02-02 01:35:54"
*/
public function get_contact_bynumber($r){ public function get_contact_bynumber($r){
return true;
return $this->get_contact_info($r["number"]); return $this->get_contact_info($r["number"]);
} }
public function get_contact_info($number){ public function get_contact_info($number){
return true;
$this->tLog($number,"--== TGM Begin GEtting Contact Info Contact: "); $this->tLog($number,"--== TGM Begin GEtting Contact Info Contact: ");
if(empty($this->TGM)){ return ''; } if(empty($this->TGM)){ return ''; }
$jsContacts = $this->TGM->getContactList(); $jsContacts = $this->TGM->getContactList();
...@@ -555,7 +550,7 @@ when: "2021-02-02 01:35:54" ...@@ -555,7 +550,7 @@ when: "2021-02-02 01:35:54"
}*/ }*/
public function set_tg_sender_default($sender=false){ public function set_tg_sender_default($sender=false){
return true;
$sender = (!empty($sender)) ? preg_replace("/[^0-9]/", '', $sender) : false; $sender = (!empty($sender)) ? preg_replace("/[^0-9]/", '', $sender) : false;
if(is_numeric($sender)){ if(is_numeric($sender)){
...@@ -589,6 +584,8 @@ when: "2021-02-02 01:35:54" ...@@ -589,6 +584,8 @@ when: "2021-02-02 01:35:54"
} }
public function send_telegram_file($p){ public function send_telegram_file($p){
return true;
if(!empty($p["from_number"])){ $this->set_tg_sender_default($p["from_number"]); } if(!empty($p["from_number"])){ $this->set_tg_sender_default($p["from_number"]); }
$telegram = $this->TGM; $telegram = $this->TGM;
$this->tLog("aTG: --=== Begin Sending TG Files... : [".json_encode($p)."]"); $this->tLog("aTG: --=== Begin Sending TG Files... : [".json_encode($p)."]");
...@@ -608,6 +605,7 @@ when: "2021-02-02 01:35:54" ...@@ -608,6 +605,7 @@ when: "2021-02-02 01:35:54"
} }
public function send_telegram_photo($p){ public function send_telegram_photo($p){
return true;
/* PARAMS /* PARAMS
- tonumber - tonumber
- path - path
...@@ -642,6 +640,7 @@ when: "2021-02-02 01:35:54" ...@@ -642,6 +640,7 @@ when: "2021-02-02 01:35:54"
} }
public function send_telegram_msg($p){ public function send_telegram_msg($p){
return true;
/* PARAMS /* PARAMS
- tonumber (or toid) - tonumber (or toid)
- message - message
...@@ -685,6 +684,7 @@ when: "2021-02-02 01:35:54" ...@@ -685,6 +684,7 @@ when: "2021-02-02 01:35:54"
public function delete_telegram_account($params){ public function delete_telegram_account($params){
return true;
if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); }
if(!empty($tgNumber)){ if(!empty($tgNumber)){
$this->stop_profile_by_number($tgNumber); $this->stop_profile_by_number($tgNumber);
...@@ -709,6 +709,7 @@ when: "2021-02-02 01:35:54" ...@@ -709,6 +709,7 @@ when: "2021-02-02 01:35:54"
} }
public function get_telegram_account_status($params){ public function get_telegram_account_status($params){
return true;
if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } else { return 'Not set Profile'; } if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } else { return 'Not set Profile'; }
$profd = "prf_".$tgNumber; $profd = "prf_".$tgNumber;
$arProfile = $this->get_tg_account_self($profd); $arProfile = $this->get_tg_account_self($profd);
...@@ -722,6 +723,7 @@ when: "2021-02-02 01:35:54" ...@@ -722,6 +723,7 @@ when: "2021-02-02 01:35:54"
} }
public function get_telegram_accounts(){ public function get_telegram_accounts(){
return true;
$tg_profiles_dir = $this->tgdir."/profiles/"; $tg_profiles_dir = $this->tgdir."/profiles/";
$tg_socks_dir = $this->tgdir."/socks/"; $tg_socks_dir = $this->tgdir."/socks/";
...@@ -767,6 +769,7 @@ when: "2021-02-02 01:35:54" ...@@ -767,6 +769,7 @@ when: "2021-02-02 01:35:54"
} }
public function register_account_confcode($params){ public function register_account_confcode($params){
return true;
if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); }
if(!empty($params["TGCONFCODE"])){ $tgNumberConfCode = preg_replace("/[^0-9]/", '', $params["TGCONFCODE"]); } if(!empty($params["TGCONFCODE"])){ $tgNumberConfCode = preg_replace("/[^0-9]/", '', $params["TGCONFCODE"]); }
if(!empty($tgNumber)){ if(!empty($tgNumber)){
...@@ -780,6 +783,7 @@ when: "2021-02-02 01:35:54" ...@@ -780,6 +783,7 @@ when: "2021-02-02 01:35:54"
} }
public function stop_profile_by_number($params){ public function stop_profile_by_number($params){
return true;
if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); }
if(empty($tgNumber)){ if(empty($tgNumber)){
return array("error"=>'No or bad Number'); return array("error"=>'No or bad Number');
...@@ -832,6 +836,7 @@ when: "2021-02-02 01:35:54" ...@@ -832,6 +836,7 @@ when: "2021-02-02 01:35:54"
} }
public function get_contacts_list_old($params){ public function get_contacts_list_old($params){
return true;
if( empty($this->currentProfile)){ $this->currentProfile ="998946712860"; } if( empty($this->currentProfile)){ $this->currentProfile ="998946712860"; }
$telegram = new \Zyberspace\Telegram\Cli\Client('unix://'.$this->tgsocks_dir.'prf_'.$this->currentProfile.'.sck'); $telegram = new \Zyberspace\Telegram\Cli\Client('unix://'.$this->tgsocks_dir.'prf_'.$this->currentProfile.'.sck');
...@@ -862,7 +867,7 @@ when: "2021-02-02 01:35:54" ...@@ -862,7 +867,7 @@ when: "2021-02-02 01:35:54"
} }
public function async_run_profile_by_number($tgNumber){ public function async_run_profile_by_number($tgNumber){
return true;
if(empty($tgNumber)){ if(empty($tgNumber)){
return array("error"=>'No or bad Numbers'); return array("error"=>'No or bad Numbers');
} }
...@@ -900,6 +905,7 @@ when: "2021-02-02 01:35:54" ...@@ -900,6 +905,7 @@ when: "2021-02-02 01:35:54"
public function register_account($params){ public function register_account($params){
return true;
$this->tLog("aTG: register_account: ".json_encode($params)); $this->tLog("aTG: register_account: ".json_encode($params));
if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); } if(!empty($params["TGNUMBER"])){ $tgNumber = preg_replace("/[^0-9]/", '', $params["TGNUMBER"]); }
$this->delete_telegram_account(["TGNUMBER"=>$tgNumber]); $this->delete_telegram_account(["TGNUMBER"=>$tgNumber]);
...@@ -917,6 +923,7 @@ when: "2021-02-02 01:35:54" ...@@ -917,6 +923,7 @@ when: "2021-02-02 01:35:54"
} }
public function getTelegramSmsSettingsPage() { public function getTelegramSmsSettingsPage() {
return true;
global $APPLICATION; global $APPLICATION;
$arAccountsList = $this->get_telegram_accounts(); $arAccountsList = $this->get_telegram_accounts();
//var_dump($arAccountsList); //var_dump($arAccountsList);
...@@ -978,6 +985,7 @@ when: "2021-02-02 01:35:54" ...@@ -978,6 +985,7 @@ when: "2021-02-02 01:35:54"
/*----------------------------INCOM----------------------------------------------*/ /*----------------------------INCOM----------------------------------------------*/
public function handleIncomingMessages($params){ public function handleIncomingMessages($params){
return true;
$this->tLog("aTG: handleIncomingMessages: |".$params."|"); $this->tLog("aTG: handleIncomingMessages: |".$params."|");
//{"to":{"last_name":"*","peer_type":"user","id":"$010000007e53ac3d557f36881c3521f6","flags":524291,"access_hash":1,"username":"texnomartstar","peer_id":1034703742,"print_name":"Texnomart_*","phone":"998946712860","first_name":"Texnomart"},"date":1576750169,"unread":true,"flags":257,"out":false,"text":"123123","service":false,"from":{"last_name":"Nava","peer_type":"user","id":"$010000001827730723b8ffcdc773a34c","flags":196609,"access_hash":1,"username":"kuldash","peer_id":124987160,"print_name":"kulya_Nava","phone":"998977076909","first_name":"kulya"},"id":"0100000018277307080000000000000023b8ffcdc773a34c"} //{"to":{"last_name":"*","peer_type":"user","id":"$010000007e53ac3d557f36881c3521f6","flags":524291,"access_hash":1,"username":"texnomartstar","peer_id":1034703742,"print_name":"Texnomart_*","phone":"998946712860","first_name":"Texnomart"},"date":1576750169,"unread":true,"flags":257,"out":false,"text":"123123","service":false,"from":{"last_name":"Nava","peer_type":"user","id":"$010000001827730723b8ffcdc773a34c","flags":196609,"access_hash":1,"username":"kuldash","peer_id":124987160,"print_name":"kulya_Nava","phone":"998977076909","first_name":"kulya"},"id":"0100000018277307080000000000000023b8ffcdc773a34c"}
$arDefIncomUsersIds = array(1,9); $arDefIncomUsersIds = array(1,9);
...@@ -1030,6 +1038,7 @@ when: "2021-02-02 01:35:54" ...@@ -1030,6 +1038,7 @@ when: "2021-02-02 01:35:54"
/*---------------------------- CONTACT -- INFO --------------------------------------------*/ /*---------------------------- CONTACT -- INFO --------------------------------------------*/
public function getcontactinfo($params){ public function getcontactinfo($params){
return true;
$telegram = new \Zyberspace\Telegram\Cli\Client($tgSocket); $telegram = new \Zyberspace\Telegram\Cli\Client($tgSocket);
$resAns = ''; $resAns = '';
$number = preg_replace("/[^0-9]/", '', $_REQUEST["getcontactinfo"]) ; $number = preg_replace("/[^0-9]/", '', $_REQUEST["getcontactinfo"]) ;
...@@ -1192,6 +1201,7 @@ when: "2021-02-02 01:35:54" ...@@ -1192,6 +1201,7 @@ when: "2021-02-02 01:35:54"
public function telegram_activity_add($params,$dir=\CCrmActivityDirection::Outgoing) { public function telegram_activity_add($params,$dir=\CCrmActivityDirection::Outgoing) {
return true;
$this->tLog("aTG: PRED Add Activity IN PARAMS: [".json_encode($params)."]"); $this->tLog("aTG: PRED Add Activity IN PARAMS: [".json_encode($params)."]");
\Bitrix\Main\Loader::includeModule('crm'); \Bitrix\Main\Loader::includeModule('crm');
$arCrmEntTypes = array( $arCrmEntTypes = array(
...@@ -1240,6 +1250,7 @@ when: "2021-02-02 01:35:54" ...@@ -1240,6 +1250,7 @@ when: "2021-02-02 01:35:54"
} }
} }
public function echo_sleep($sec, $msg = false, $newline = false) { public function echo_sleep($sec, $msg = false, $newline = false) {
return true;
global $echo_sleep_prev_msg_gb; // Preeventing to show the same msg. global $echo_sleep_prev_msg_gb; // Preeventing to show the same msg.
if ($echo_sleep_prev_msg_gb !== $msg) { if ($echo_sleep_prev_msg_gb !== $msg) {
if ($msg) $this->tLog( $msg ); if ($msg) $this->tLog( $msg );
...@@ -1251,7 +1262,7 @@ when: "2021-02-02 01:35:54" ...@@ -1251,7 +1262,7 @@ when: "2021-02-02 01:35:54"
} }
public function check_and_register_tg($tgnumber) { public function check_and_register_tg($tgnumber) {
return true;
$this->tLog("Alo TG Reginster begin number: ".$tgnumber); $this->tLog("Alo TG Reginster begin number: ".$tgnumber);
$this->echo_sleep(1, "Loading config", true); $this->echo_sleep(1, "Loading config", true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment