Answer the question
In order to leave comments, you need to log in
Why is the required line not displayed in the VK bot?
Hello! I have a bot, but I don't understand why it doesn't print "last line" even though everything else works
Code:
from vkbottle.bot import Bot, Message
import config
bot = Bot('token')
@bot.on.message(text ='')
async def what(ans: Message, msg):
i = 0
if msg.lower() == 'start' or msg.lower() == 'start':
await ans.answer('select something ', keyboard = config.keyboard)
elif msg.lower() == 'something':
i = 1
await ans.answer('Great! Since you chose something else...', keyboard = config. today)
elif msg.lower() == 'something else' and i == 1:
await ans.answer('
bot.run_forever()
Answer the question
In order to leave comments, you need to log in
A similar example that would suit you is already on the github of the framework. And it makes no sense to shove all commands into 1 function
Most likely, the point is that your code is executed asynchronously, and it is not known exactly what value the variable i will have when the last condition is checked. Check it with print()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question