YaxaMedia
  1. <?php
  2.  
  3. // token maydoni
  4. define('bot_token','624400229:AAGieD6uZR_4dVvYD6zD0zmCt7fUTbTJvIM');
  5.  
  6. function xabarYubor(array $content)
  7. {
  8. return endpoint('sendMessage', $content);
  9. }
  10.  
  11. function buildKeyBoard(array $options, $onetime = false, $resize = true, $selective = true)
  12. {
  13. $replyMarkup = [
  14. 'keyboard' => $options,
  15. 'one_time_keyboard' => $onetime,
  16. 'resize_keyboard' => $resize,
  17. 'selective' => $selective,
  18. ];
  19. $encodedMarkup = json_encode($replyMarkup, true);
  20.  
  21. return $encodedMarkup;
  22. }
  23.  
  24. function bot($method,$datas=[]){
  25. $url = "https://api.telegram.org/bot".bot_token."/".$method;
  26.  
  27. function endpoint($api, array $content, $post = true)
  28. {
  29. $url = 'https://api.telegram.org/bot'.bot_token.'/'.$api;
  30. if ($post) {
  31. $reply = sendAPIRequest($url, $content);
  32. } else {
  33. $reply = sendAPIRequest($url, [], false);
  34. }
  35.  
  36. return json_decode($reply, true);
  37. }
  38.  
  39. function sendAPIRequest($url, array $content, $post = true)
  40. {
  41. if (isset($content['chat_id'])) {
  42. $url = $url.'?chat_id='.$content['chat_id'];
  43.  
  44. //$url = $url.'?'.http_build_query($content);
  45.  
  46. unset($content['chat_id']);
  47. //unset($content);
  48. }
  49. $ch = curl_init();
  50. curl_setopt($ch, CURLOPT_URL, $url);
  51. curl_setopt($ch, CURLOPT_HEADER, false);
  52. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  53. if ($post) {
  54. curl_setopt($ch, CURLOPT_POST, 1);
  55. curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
  56. }
  57. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  58. $result = curl_exec($ch);
  59. if ($result === false) {
  60. $result = json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch), 'curl_error' => curl_error($ch)]);
  61. }
  62. curl_close($ch);
  63.  
  64. return $result;
  65. }
  66.  
  67. function buildForceReply($selective = true)
  68. {
  69. $replyMarkup = [
  70. 'force_reply' => true,
  71. 'selective' => $selective,
  72. ];
  73. $encodedMarkup = json_encode($replyMarkup, true);
  74.  
  75. return $encodedMarkup;
  76. }
  77.  
  78.  
  79. // uzizni ID raqamingizni kiritasiz
  80. $admin = "542680109";
  81.  
  82. // BOT iz username si
  83. $bot_name = "qarawilrobot";
  84. // manba @gayratfayz kanali
  85.  
  86. $efede = json_decode(file_get_contents('php://input'), true);
  87.  
  88. //basic
  89. $text = $efede["message"]["text"];
  90. $photo = $efede["message"]["photo"];
  91. $sana = $efede["message"]["date"];
  92. $chat_id = $efede["message"]["chat"]["id"];
  93.  
  94. // chat
  95. $cfname = $efede["message"]["chat"]["first_name"];
  96. $cid = $efede["message"]["chat"]["id"];
  97. $clast_name = $efede["message"]["chat"]["last_name"];
  98. $turi = $efede["message"]["chat"]["type"];
  99.  
  100. //user info
  101. $ufname = $efede["message"]["from"]["first_name"];
  102. $uname = $efede["message"]["from"]["last_name"];
  103. $ulogin = $efede["message"]["from"]["username"];
  104. $uid = $efede["message"]["from"]["id"];
  105. $user_id = $efede["message"]["from"]["id"];
  106.  
  107. //reply info
  108. $sreply = $efede["message"]["reply_to_message"]["text"];
  109.  
  110.  
  111. // umumiy menu
  112. $menu = [["ℹMen haqimda"],["?Xabar yozish"],["?Bot haqida"]];
  113.  
  114.  
  115.  
  116. if ($text == '/start') {
  117. $keyfd = buildKeyBoard($menu, $onetime = false, $resize = true);
  118. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "*✋Assalomu alaykum $ufname $uname*", 'parse_mode' => 'markdown'];
  119.  
  120. xabarYubor($content);
  121. }
  122.  
  123. if ($text == 'ℹMen haqimda') {
  124.  
  125. $keyfd = buildKeyBoard($menu, $onetime = false, $resize = true);
  126. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "*Siz haqingizda!*
  127. _?Ismingiz:_ $ufname
  128. _?Familiyangiz:_ $uname
  129. _?Loginingiz:_ @$ulogin
  130. _?raqamingiz:_ $user_id
  131. _?guruh:_ $uid", 'parse_mode' => 'markdown'];
  132.  
  133. xabarYubor($content);
  134. }
  135.  
  136. if ($text == '?Bot haqida') {
  137.  
  138. $keyfd = buildKeyBoard($menu, $onetime = false, $resize = true);
  139. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "*Salom $ufname botimiz orqali siz admin bilan bog‘lanishingiz mumkin!*
  140. _Bot_ @gayratfayz _Media Group® tomonidan yaratildi?_", 'parse_mode' => 'markdown'];
  141.  
  142. xabarYubor($content);
  143. }
  144.  
  145. if ($text == '/feedback' || $text == "?Xabar yozish"){
  146. $keyfd = buildForceReply($selective=true);
  147. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "*Xabar matnini kiriting*", 'parse_mode' => 'markdown'];
  148. xabarYubor($content);
  149. }
  150.  
  151. if ($sreply == 'Xabar matnini kiriting'){
  152.  
  153. $option = $menu;
  154. $keyfd = buildKeyBoard($option, $onetime = false);
  155. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "*?Xabaringiz bizga yetib keldi?*
  156.  
  157. _?Tez orada javob qaytaramiz✍_", 'parse_mode' => 'markdown'];
  158. xabarYubor($content);
  159.  
  160. $option = [["javob#$chat_id"]];
  161. $keyfd = buildKeyBoard($option, $onetime = false);
  162. $content = ['chat_id' => $admin, 'reply_markup' => $keyfd, 'text' => "Yangi Xabar \n Kimdan: $ufname $uname \n Login: @$ulogin \n ID: $uid \n\n Matn: $text", 'parse_mode' => 'markdown'];
  163. xabarYubor($content);
  164. }
  165.  
  166. $inreg = explode("#",$text);
  167. $intype = $inreg[0];
  168. $us_id = $inreg[1];
  169.  
  170. if ($intype == 'javob') {
  171.  
  172. $keyfd = buildForceReply($selective=true);
  173. $content = ['chat_id' => $chat_id, 'reply_markup' => $keyfd, 'text' => "javob matnini kiriting#$us_id", 'parse_mode' => 'markdown'];
  174. xabarYubor($content);
  175. }
  176.  
  177. $inreg = explode("#",$sreply);
  178. $intype = $inreg[0];
  179. $us_id = $inreg[1];
  180.  
  181. if ($intype == 'javob matnini kiriting'){
  182.  
  183. $option = $menu;
  184. $keyfd = buildKeyBoard($option, $onetime = false);
  185. $content = ['chat_id' => $us_id, 'reply_markup' => $keyfd, 'text' => $text, 'parse_mode' => 'markdown'];
  186. xabarYubor($content);
  187.  
  188. $option = $menu;
  189. $keyfd = buildKeyBoard($option, $onetime = false);
  190. $content = ['chat_id' => $admin, 'reply_markup' => $keyfd, 'text' => "Xabar yetkazildi", 'parse_mode' => 'markdown'];
  191. xabarYubor($content);
  192. }

3 daqiqa 42 soniyadan keyin yozdi:
tekshirip beringlar