Answer the question
In order to leave comments, you need to log in
How to write vkbottle state selection into a separate function?
@bot.on.private_message(payload = {"cmd":"yeslvlup"})
async def yeslvlup(message: Message):
lvl = 1+base.output_lvl(message.peer_id)
base.input_lvl(message.peer_id,lvl)
if lvl == 2:
await bot.state_dispenser.set(message.peer_id, func.Data.SecondLvl)
elif lvl == 3:
await bot.state_dispenser.set(message.peer_id, func.Data.ThirdLvl)
elif lvl == 4:
await bot.state_dispenser.set(message.peer_id, func.Data.FourthLvl)
elif lvl == 5:
await bot.state_dispenser.set(message.peer_id, func.Data.FifthLvl)
elif lvl == 6:
await bot.state_dispenser.set(message.peer_id, func.Data.SixthLvl)
elif lvl == 7:
await bot.state_dispenser.set(message.peer_id, func.Data.SeventhLvl)
await message.text(
"Уровень повышен",
keyboard = Keyboard(one_time = True)
.add(Text("Продолжить"), color = KeyboardButtonColor.PRIMARY)
)
Answer the question
In order to leave comments, you need to log in
Didn't work with vkbottle, but you can try this
async def set_state(peer_id, lvl):
states = {
2: func.Data.SecondLvl,
3: func.Data.ThirdLvl,
4: func.Data.FourthLvl,
5: func.Data.FifthLvl,
6: func.Data.SixthLvl,
7: func.Data.SeventhLvl
}
await bot.state_dispenser.set(peer_id, states[lvl])
@bot.on.private_message(payload = {"cmd":"yeslvlup"})
async def yeslvlup(message: Message):
lvl = 1+base.output_lvl(message.peer_id)
base.input_lvl(message.peer_id,lvl)
await set_state(message.peer_id, lvl)
await message.text(
"Уровень повышен",
keyboard = Keyboard(one_time = True)
.add(Text("Продолжить"), color = KeyboardButtonColor.PRIMARY)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question