Advertisement
Guest User

bp

a guest
Jun 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. import telebot
  2. from random import *
  3.  
  4. bot = telebot.TeleBot("819452497:AAEyEtgrW50WLM9sR1Kp37VeICQGNBFQRhY")
  5.  
  6. a = -1
  7. b = -1
  8.  
  9. @bot.message_handler(content_types=["text"])
  10. def check(mes):
  11. global a, b
  12. id = mes.chat.id
  13. text = mes.text
  14. if text == "/start":
  15. if id != a and id != b:
  16. bot.send_message(id, "Enter a password:")
  17. else:
  18. bot.send_message(id, "You have already entered the chat.")
  19. elif text != "/quit":
  20. if id != a and id != b:
  21. if text == "hjPN31DP":
  22. if a == -1:
  23. a = id
  24. bot.send_message(id, "Successful!")
  25. if b != -1:
  26. bot.send_message(b, "The second user has entered!")
  27. elif b == -1:
  28. b = id
  29. bot.send_message(id, "Successful!")
  30. if a != -1:
  31. bot.send_message(a, "The second user has entered!")
  32. else:
  33. bot.send_message(id, "Both users have already entered the chat. Come again later. Sorry.")
  34. else:
  35. bot.send_message(id, "Invalid password. Try again.")
  36. else:
  37. if id == a:
  38. if b == -1:
  39. bot.send_message(id, "Wait for the second user to enter...")
  40. else:
  41. bot.send_message(b, text)
  42. else:
  43. if a == -1:
  44. bot.send_message(id, "Wait for the second user to enter...")
  45. else:
  46. bot.send_message(a, text)
  47. else:
  48. if id == a:
  49. a = -1
  50. bot.send_message(id, "You have quit the chat.")
  51. elif id == b:
  52. b = -1
  53. bot.send_message(id, "You have quit the chat.")
  54. else:
  55. bot.send_message(id, "You haven't entered the chat yet.")
  56.  
  57.  
  58. bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement