The problem is, that my variable does not get plus up, it just becomes "0" and pluses another value. Don't get worried, my code is okay. I get 0 on every new ELIF. BTW, I don't use global
statement, cause i am developing multi club bot.
here is my code:
def pointsDB():
import dPoints
dPoints = 0
return dPoints
@bot.message_handler(content_types=['text'])
def startingTest(message):
dPoints = pointsDB()
while message.text == str(q21s1.text) or str(q21s2.text) or str(q21s3.text) or str(q21s4.text):
if message.chat.type == "private":
if message.text == "Начать тест":
print(UserName + " начал тест")
markup = telebot.types.ReplyKeyboardRemove()
bot.send_message(message.chat.id, "ИНСТРУКЦИЯ".format(
message.from_user, bot.get_me()), reply_markup=markup)
time.sleep(1.5)
bot.send_message(message.chat.id, "Группа #1".format(
message.from_user, bot.get_me()), reply_markup=q1)
print(UserName + " " + str(dPoints) + " points")
break
elif message.text == str(q1s1.text) or message.text == str(q1s2.text) or message.text == str(q1s3.text) or message.text == str(q1s4.text):
if message.text == str(q1s1.text):
dPoints += 0
print(UserName + " " + message.text)
elif message.text == str(q1s2.text):
dPoints += 1
print(UserName + " " + message.text)
elif message.text == str(q1s3.text):
dPoints += 2
print(UserName + " " + message.text)
elif message.text == str(q1s4.text):
dPoints += 3
print(UserName + " " + message.text)
markup = telebot.types.ReplyKeyboardRemove()
time.sleep(1)
bot.send_message(message.chat.id, "Вы ответили на 1 из 21 вопросов".format(
message.from_user, bot.get_me()), reply_markup=markup)
time.sleep(2)
bot.send_message(message.chat.id, "Группа #2".format(
message.from_user, bot.get_me()), reply_markup=q2)
print(UserName + " " + str(dPoints) + " points")
break
elif message.text == str(q2s1.text) or message.text == str(q2s2.text) or message.text == str(q2s3.text) or message.text == str(q2s4.text):
if message.text == str(q2s1.text):
dPoints += 0
print(UserName + " " + message.text)
elif message.text == str(q2s2.text):
dPoints += 1
print(UserName + " " + message.text)
elif message.text == str(q2s3.text):
dPoints += 2
print(UserName + " " + message.text)
elif message.text == str(q2s4.text):
print(UserName + " " + str(dPoints) + " points")
dPoints += 3
print(UserName + " " + message.text)
markup = telebot.types.ReplyKeyboardRemove()
time.sleep(1)
bot.send_message(message.chat.id, "Вы ответили на 2 из 21 вопросов".format(
message.from_user, bot.get_me()), reply_markup=markup)
time.sleep(2)
bot.send_message(message.chat.id, "Группа #3".format(
message.from_user, bot.get_me()), reply_markup=q3)
print(UserName + " " + str(dPoints) + " points")
break
The output i get is:
"UserName" 0 Points
"UserName" 2 Points (can be 0,1,2,3)
"UserName" 0 Points
"Username" 3 Points (can be 0,1,2,3)
Aucun commentaire:
Enregistrer un commentaire