Advertisement
Guest User

Code PHP

a guest
Nov 13th, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2.  
  3.   $botToken = "Token bello";
  4.   $website = "https://api.telegram.org/bot".$botToken;
  5.  
  6.  
  7.   $update = file_get_contents('php://input');
  8.   $update = json_decode($update, TRUE);
  9.  
  10.   $chatId = $update['message']['from']['id'];
  11.   $nome = $update['message']['from']['first_name'];
  12.   $text = $update['message']['text'];
  13.  
  14.  
  15.   $agg = json_decode($update,JSON_PRETTY_PRINT);
  16.  
  17.  
  18.   switch($text)
  19.   {
  20.   case "Contatti":
  21.   sendMessage($chatId,"Se vuoi contattarci in privato per bug o errori su questo bot o altre cose:
  22. Lorenzo: @LorenzoTM88 (Founder)
  23. enenen: @enenen (Admin)
  24. enenen: @enenen (Admin)
  25. Per limitati: @HWHelpBot
  26. Mi raccomando, quando scrivete in privato avvisate che venite dal bot, o verrete spamreportati!
  27. Grazie :D");
  28.   break;
  29.   case "Finire":
  30.   sendMessage($chatId,"Finire");
  31.   break;
  32.   case "Info":
  33.   sendMessage($chatId,"Nel gruppo si parla di informatica, bot, programmazione, PC, configurazioni, elettronica... diciamo un pò di tutto!
  34. Hai problemi sul PC? Ti serve assistenza? Devi comprare un PC ma non sai se i componenti sono compatibili? Devi chiedere un parere su un alimentatore?
  35. Ecco, CHIEDI TUTTO A NOI!");
  36.   break;
  37.   default:
  38.   $tastierabenvenuto = '["Info"],["Contatti"],["Finire"]';
  39.   sendMessage($chatId,"Ciao <b>$nome</b>!
  40. Questo bot ti darà info sul gruppo @HWGroupTech!
  41. Clicca i vari pulsanti per avere altre info sul gruppo!",$tastierabenvenuto);
  42.   break;
  43.   }
  44.   function sendMessage($chatId,$text,$tastiera)
  45.   {
  46.     if(isset($tastiera))
  47.     {
  48.     $tastierino = '&reply_markup={"keyboard":['.$tastiera.'],"resize_keyboard":true}';
  49.     }
  50.   $url = $GLOBALS[website]."/sendMessage?chat_id=$chatId&parse_mode=HTML&text=".urlencode($text).$tastierino;
  51.   file_get_contents($url);
  52.   }
  53.  
  54.  
  55.   ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement