Не рабочая чат-рулетка в Телебот, Python. Что делать?
Создаю некое подобие бота-чат рулетки, около шести часов писал-не работает. Данные получает, ID получает, но не Принт-ит и не проходит к этапу коннекта между пользователями.
import telebot
from telebot import types
import random
import string
bot=telebot.TeleBot(<<Токен>>)
xoba="6"
neta=0
deta=0
users={xoba:"8"}
isinhere=False
everyone=0
@bot.message_handler(content_types="text")
def start(message):
global isinhere
global users
global xoba
global deta
global everyone
if message.text=="Начнём":
chatid=message.chat.id
try:
deta=deta+1
for i in range(deta):
if users[deta][0]["id"]==chatid:
isinhere=True
deta=deta-1
except:
deta=deta-1
for i in range(deta):
if users[deta][0]["id"] == chatid:
isinhere = True
if isinhere==False:
deta = deta + 1
bot.send_message(message.from_user.id, "Поздравляю, вы в чат-рулетке. Ищем вам человека.")
letters = string.ascii_lowercase
peta = ''.join(random.choice(letters) for i in range(10))
idfirst={"id":chatid}
msgfirst={"msg":neta}
codefirst={"code":peta}
users[deta]=idfirst, msgfirst, codefirst
everyone=True
try:
del users[xoba]
except:
pass
print(users)
isinhere=False
else:
bot.send_message(message.from_user.id, "Вы уже в очереди, остаётся только ждать!")
else:
bot.send_message(message.from_user.id, "Напишите 'Начнём'")
@bot.message_handler(content_types="button")
def Hola(message):
markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
btn1 = types.ReplyKeyboardButton(text="Начнём")
markup.add(btn1)
conf1={xoba:8}
conf2={xoba:8}
conf3={xoba:8}
conf4={xoba:8}
conf5={xoba:8}
if everyone==True:
print(1 in users)
print(2 in users)
while everyone==True:
print(1 in users)
print(2 in users)
if 1 in users and 2 in users:
if xoba in conf1:
conf1active=True
conf1first=users[1]
del users[1]
conf1second = users[2]
del users[2]
deta=deta-2
for i in range(deta):
inter=3
users[i]=inter-2
inter=inter+1
del conf1[xoba]
conf1[1]=conf1first
conf1[2]=conf1second
print(users)
if xoba in conf2:
conf2active = True
conf2first = users[1]
del users[1]
conf2second = users[2]
del users[2]
deta = deta - 2
for i in range(deta):
inter = 3
users[i] = inter - 2
inter = inter + 1
del conf2[xoba]
conf2[1] = conf2first
conf2[2] = conf2second
print(users)
if xoba in conf3:
conf3active = True
conf3first = users[1]
del users[1]
conf3second = users[2]
del users[2]
deta = deta - 2
for i in range(deta):
inter = 3
users[i] = inter - 2
inter = inter + 1
del conf3[xoba]
conf3[1] = conf3first
conf3[2] = conf3second
print(users)
if xoba in conf4:
conf4active = True
conf4first = users[1]
del users[1]
conf4second = users[2]
del users[2]
deta = deta - 2
for i in range(deta):
inter = 3
users[i] = inter - 2
inter = inter + 1
del conf4[xoba]
conf4[1] = conf4first
conf4[2] = conf4second
print(users)
if xoba in conf5:
conf5active = True
conf5first = users[1]
del users[1]
conf5second = users[2]
del users[2]
deta = deta - 2
for i in range(deta):
inter = 3
users[i] = inter - 2
inter = inter + 1
del conf5[xoba]
conf5[1] = conf5first
conf5[2] = conf5second
if conf1active:
@bot.message_handler(content_types="text")
def connect(message):
bot.send_message(conf1first["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
bot.send_message(conf1second["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
while conf1active==True:
@bot.message_handler(content_types="text")
def msgs(message):
checkid=message.chat.id
global conf1first
global conf1second
global conf1active
if checkid==conf1first["id"]:
conf1first["msg"]=message.text
bot.send_message(conf1second["id"], text=conf1first["msg"])
if checkid==conf1second["id"]:
conf1second["msg"]=message.text
bot.send_message(conf1first["id"], text=conf1second["msg"])
if message.text=="/Выход" or message.text=="/выход":
bot.send_message(conf1first["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
bot.send_message(conf1second["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
conf1second="Empty"
conf1first="Empty"
conf1active=False
if conf2active:
@bot.message_handler(content_types="text")
def connect(message):
bot.send_message(conf2first["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
bot.send_message(conf2second["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
while conf2active == True:
@bot.message_handler(content_types="text")
def msgs(message):
checkid = message.chat.id
global conf2first
global conf2second
global conf2active
if checkid == conf2first["id"]:
conf2first["msg"] = message.text
bot.send_message(conf2second["id"], text=conf2first["msg"])
if checkid == conf2second["id"]:
conf2second["msg"] = message.text
bot.send_message(conf2first["id"], text=conf2second["msg"])
if message.text == "/Выход" or message.text == "/выход":
bot.send_message(conf2first["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
bot.send_message(conf2second["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
conf2second = "Empty"
conf2first = "Empty"
conf2active = False
if conf3active:
@bot.message_handler(content_types="text")
def connect(message):
bot.send_message(conf3first["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
bot.send_message(conf3second["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
while conf3active == True:
@bot.message_handler(content_types="text")
def msgs(message):
checkid = message.chat.id
global conf3first
global conf3second
global conf3active
if checkid == conf3first["id"]:
conf3first["msg"] = message.text
bot.send_message(conf3second["id"], text=conf3first["msg"])
if checkid == conf3second["id"]:
conf3second["msg"] = message.text
bot.send_message(conf3first["id"], text=conf3second["msg"])
if message.text == "/Выход" or message.text == "/выход":
bot.send_message(conf3first["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
bot.send_message(conf3second["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
conf3second = "Empty"
conf3first = "Empty"
conf3active = False
if conf4active:
@bot.message_handler(content_types="text")
def connect(message):
bot.send_message(conf1first["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
bot.send_message(conf1second["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
while conf1active == True:
@bot.message_handler(content_types="text")
def msgs(message):
checkid = message.chat.id
global conf4first
global conf4second
global conf4active
if checkid == conf1first["id"]:
conf4first["msg"] = message.text
bot.send_message(conf4second["id"], text=conf4first["msg"])
if checkid == conf4second["id"]:
conf4second["msg"] = message.text
bot.send_message(conf4first["id"], text=conf4second["msg"])
if message.text == "/Выход" or message.text == "/выход":
bot.send_message(conf4first["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
bot.send_message(conf4second["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
conf4second = "Empty"
conf4first = "Empty"
conf4active = False
if conf5active:
@bot.message_handler(content_types="text")
def connect(message):
bot.send_message(conf5first["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
bot.send_message(conf5second["id"], "Вы подключены! Для окончания диалога напишите '/Выход'.")
while conf5active == True:
@bot.message_handler(content_types="text")
def msgs(message):
checkid = message.chat.id
global conf5first
global conf5second
global conf5active
if checkid == conf1first["id"]:
conf5first["msg"] = message.text
bot.send_message(conf5second["id"], text=conf5first["msg"])
if checkid == conf5second["id"]:
conf5second["msg"] = message.text
bot.send_message(conf5first["id"], text=conf5second["msg"])
if message.text == "/Выход" or message.text == "/выход":
bot.send_message(conf5first["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
bot.send_message(conf5second["id"], "Диалог окончен, напишите 'Начнём' для начала нового.")
conf5second = "Empty"
conf5first = "Empty"
conf5active = False
bot.polling(none_stop=True, interval=0)