Guest User

Untitled

a guest
Oct 30th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.77 KB | None | 0 0
  1. <?php
  2. $postgHeader = "Новости юрисдикций";
  3. $posTG_title = "Рубль и ОФЗ дорожают на фоне общего оптимизма, задвинувшего в угол геополитику";
  4. $tgpic = "rechtsanwalt-gmbh.ru/images/Countries/All/All_10.jpg";
  5. $postgLink_news = "https://rechtsanwalt-gmbh.ru/business-news-mail.html?news_id=5592";
  6. $postgLink_pieces = explode("://", $postgLink_news);
  7. $postgLink_piece = explode("/", $postgLink_pieces[1]);
  8. $postgLink_title = $postgLink_piece[0];
  9.  
  10.  
  11. $botToken = "***";
  12. $chat_id = "@new_rech_test";
  13. $message = $postgHeader.":* ".$posTG_title." [%7F](".$tgpic.")";
  14. $bot_url = "https://api.telegram.org/bot$botToken/";
  15. $url = $bot_url."sendMessage?chat_id=".$chat_id."&parse_mode=Markdown"."&text=*".urlencode($message);
  16.  
  17.  
  18. $buttons = json_encode([
  19.     "inline_keyboard" => [
  20.         // первый ряд
  21.         [
  22.             // первая кнопка первого ряда
  23.             [
  24.                 "text" => "👍",
  25.                 "callback_data" => "/like"
  26.             ],
  27.             // вторая кнопка первого ряда
  28.             [
  29.                 "text" => "😐",
  30.                 "callback_data" => "/neutral"
  31.             ],
  32.             // третья кнопка второго ряда
  33.             [
  34.                 "text" => "👎",
  35.                 "callback_data" => "/dislike"
  36.             ]
  37.         ],
  38.         // второй ряд
  39.         [
  40.             // первая кнопка второго ряда
  41.             [
  42.                 "text"=>$postgLink_title,
  43.                 "url"=>$postgLink_news
  44.             ],
  45.         ]
  46.     ]
  47. ], true);
  48.  
  49.  
  50. $content = file_get_contents($url."&reply_markup=".$buttons);
  51. $updates = json_decode(file_get_contents("php://input") ,true);
  52. $callback_query = $updates["callback_query"];
  53. $cq_command = mb_strtolower($callback_query["data"]);
  54.  
  55. $like = '👍';
  56. $neutral = '😐';
  57. $dislike = '👎';
  58. $sum = 0;
  59.  
  60. $updates = json_decode(file_get_contents("php://input") ,true);
  61. if($updates['update_id']) {
  62.     if($callback_query['data'] == '/like') {
  63.         $sum = $sum + 1;
  64.         $botToken = "***";
  65.         $chat_id = "@new_rech_test";
  66.         $message1 = "Лайк нажат";
  67.         $bot_url = "https://api.telegram.org/bot$botToken/";
  68.         $messageId = $callback_query["message"]["message_id"];
  69.         $new_buttons = json_encode([
  70.             "inline_keyboard" => [
  71.                 // первый ряд
  72.                 [
  73.                     // первая кнопка первого ряда
  74.                     [
  75.                         "text" => $like.$sum,
  76.                         "callback_data" => "/like"
  77.                     ],
  78.                     // вторая кнопка первого ряда
  79.                     [
  80.                         "text" => $neutral,
  81.                         "callback_data" => "/neutral"
  82.                     ],
  83.                     // третья кнопка второго ряда
  84.                     [
  85.                         "text" => $dislike,
  86.                         "callback_data" => "/dislike"
  87.                     ]
  88.                 ],
  89.                 // второй ряд
  90.                 [
  91.                     // первая кнопка второго ряда
  92.                     [
  93.                         "text"=>$postgLink_title,
  94.                         "url"=>$postgLink_news
  95.                     ],
  96.                 ]
  97.             ]
  98.         ], true);
  99.         $urledit = $bot_url."editMessageReplyMarkup?chat_id=".$chat_id."&message_id=".$messageId."&reply_markup=".$new_buttons;
  100.         file_get_contents($urledit);
  101.         $updates = json_decode(file_get_contents("php://input") ,true);
  102.         $callback_query = $updates["callback_query"];
  103.         $cq_command = mb_strtolower($callback_query["data"]);
  104.     }
  105. }
  106. else {
  107.     $updates = json_decode(file_get_contents("php://input") ,true);
  108.     $callback_query = $updates["callback_query"];
  109.     $cq_command = mb_strtolower($callback_query["data"]);
  110. }
  111. ?>
Add Comment
Please, Sign In to add comment