Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.11 KB | None | 0 0
  1. public function sendTgUsers($text,$type){
  2.         $text = urlencode($text);
  3.         $res = $this->db->query("SELECT `id`,`chat_id`,`subscribeCount` FROM `users` WHERE `subscribeCount`>'0' and `active`='1';");
  4.         if($res->num_rows > 0){
  5.             while ($row = $res->fetch_assoc()) {
  6.                 $url = "https://api.telegram.org/bot".$this->botToken."/sendMessage?chat_id=".$row['chat_id']."&parse_mode=MarkDown&text=".$text;
  7.                 $this->db->("INSERT INTO `messages` (`user_id`,`message`,`created_at`,`type`) VALUES('".$row['id']."','".$url."',NOW(),'".$type."');");
  8.                 if($type == "prognoz"){
  9.                     $this->db->query("UPDATE `users` SET `subscribeCount`=`subscribeCount`-'1' WHERE `id`='".$row['id']."';");
  10.                     $row['subscribeCount']--;
  11.                     if($row['subscribeCount'] == 0){
  12.                         $url = "https://api.telegram.org/bot".$this->botToken."/sendMessage?chat_id=".$row['chat_id']."&parse_mode=MarkDown&text=".textEndPodpiska."&reply_markup=".$keyboardBuySuscribe;
  13.                         $this->db->query("INSERT INTO `messages` (`user_id`,`message`,`created_at`,`type`) VALUES('".$row['id']."','".$url."',NOW(),'info');");
  14.                         $res = $this->file_get_contents_proxy($url,true,true);
  15.                     }
  16.                     elseif($row['subscribeCount'] == 5){
  17.                         $url = "https://api.telegram.org/bot".$this->botToken."/sendMessage?chat_id=".$row['chat_id']."&parse_mode=MarkDown&text=".textNearlyPodpiska."&reply_markup=".$keyboardBuySuscribe;
  18.                         $this->db->query("INSERT INTO `messages` (`user_id`,`message`,`created_at`,`type`) VALUES('".$row['id']."','".$url."',NOW(),'info');");
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.     }
  24.  
  25.     public function sendTgChanel($text){
  26.         $text = urlencode($text);
  27.         $url = "https://api.telegram.org/bot".$this->botToken."/sendMessage?chat_id=@jetstavka&parse_mode=MarkDown&text=".$text;
  28.         $res = $this->file_get_contents_proxy($url,true,true);
  29.         return $res['result']['message_id'];
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement