D
D
DADDDADA2021-07-22 02:35:26
Python
DADDDADA, 2021-07-22 02:35:26

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

2 answer(s)
W
WolfInChains, 2021-07-22
@DADDADADA

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

E
EgorSvinarev, 2021-07-22
@EgorSvinarev

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 question

Ask a Question

731 491 924 answers to any question