Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from random import *
- bot = telebot.TeleBot("819452497:AAEyEtgrW50WLM9sR1Kp37VeICQGNBFQRhY")
- a = -1
- b = -1
- @bot.message_handler(content_types=["text"])
- def check(mes):
- global a, b
- id = mes.chat.id
- text = mes.text
- if text == "/start":
- if id != a and id != b:
- bot.send_message(id, "Enter a password:")
- else:
- bot.send_message(id, "You have already entered the chat.")
- elif text != "/quit":
- if id != a and id != b:
- if text == "hjPN31DP":
- if a == -1:
- a = id
- bot.send_message(id, "Successful!")
- if b != -1:
- bot.send_message(b, "The second user has entered!")
- elif b == -1:
- b = id
- bot.send_message(id, "Successful!")
- if a != -1:
- bot.send_message(a, "The second user has entered!")
- else:
- bot.send_message(id, "Both users have already entered the chat. Come again later. Sorry.")
- else:
- bot.send_message(id, "Invalid password. Try again.")
- else:
- if id == a:
- if b == -1:
- bot.send_message(id, "Wait for the second user to enter...")
- else:
- bot.send_message(b, text)
- else:
- if a == -1:
- bot.send_message(id, "Wait for the second user to enter...")
- else:
- bot.send_message(a, text)
- else:
- if id == a:
- a = -1
- bot.send_message(id, "You have quit the chat.")
- elif id == b:
- b = -1
- bot.send_message(id, "You have quit the chat.")
- else:
- bot.send_message(id, "You haven't entered the chat yet.")
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement