Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2.  
  3. // Telegram URL, token, API url
  4. define('TOKEN', '***BOT_TOKEN***');
  5. define('URL', 'https://api.telegram.org/bot'.TOKEN.'/');
  6.  
  7. // Bot input
  8. $input = json_decode(file_get_contents('php://input'), true);
  9.  
  10. // User data
  11. $chat_id = $input['message']['chat']['id'];
  12. $username = $input['message']['from']['username'];
  13. $full_name = $input['message']['from']['last_name'].' '.$input['message']['from']['first_name'];
  14. $date = $input['message']['date'];
  15. $text = $input['message']['text'];
  16.  
  17. // User auth
  18.  
  19. if ( explode( ' ', $text )[1] == SITE_TOKEN ){
  20.  
  21. $user = $DB->select( 'users', $chat_id );
  22.  
  23. if ( !$user ){
  24.  
  25. $userPassword = generatePassword();
  26.  
  27. $DB->insert( 'users', makeUser( $chat, $userPassword, $full_name, $date ) );
  28.  
  29. send_keyb(
  30. $chat,
  31. "Добро пожаловать, {$full_name}. Вы зарегистрированы как {$username}!
  32. Пароль для доступа к сайту: {$userPassword}",
  33. mainMenu()
  34. );
  35. }
  36.  
  37. else {
  38. send_keyb(
  39. $chat,
  40. "Вы уже зарегистрированы как {$username}!
  41. Чтобы восстановить пароль, нажмите: /forot_password",
  42. mainMenu()
  43. );
  44. }
  45. }
  46. ?>
  47.  
  48. {"update_id":000000000,"message":{"message_id":0000,
  49. "from":{"id":000000000,"is_bot":false,"first_name":"FIRST_NAME","username":"USERNAME","language_code":"en-US"},
  50. "chat":{"id":000000000,"FIRST_NAME":"#","username":"USERNAME","type":"private"}, "date":1505645689,
  51.  
  52. /// USER TOKEN FROM SITE
  53.  
  54. "text":"/start 2a79RhELHUoC5stlOqI6pnz1bTmjuFMWSdye8xKZi4XcG0VNrJPBA3gfQDwkYv",
  55.  
  56. "entities":[{"offset":0,"length":6,"type":"bot_command"}]}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement