pythonvk

vkbottle BaseStateGroup asks for another class


I have code like this and I am trying to make a State.

from vkbottle.bot import Bot, Message
from vkbottle import Keyboard, KeyboardButtonColor, Text
from vkbottle_types import BaseStateGroup
class SuperStates(BaseStateGroup):
  NAME = 0


@bot.on.message(state=SuperStates.NAME)  # StateRule(SuperStates.AWKWARD_STATE)
async def awkward_handler(message: Message):
   await message.answer("oi awkward")

@bot.on.message(lev="/die")
async def die_handler(message: Message):
   await bot.state_dispenser.set(message.peer_id, SuperStates.NAME)
   return "ok"

Here is the error and I can't figure out what is causing it.

 raise DeprecationWarning(
DeprecationWarning: BaseStateGroup from vkbottle_types is deprecated and will be removed in future releases, use vkbottle.BaseStateGroup instead

Solution

  • First: you have a warning there, not an error.

    The warning is triggered because your code will not work in future versions of vkbottle.

    To fix this, just do what the warning suggests:

    use...

    from vkbottle import BaseStateGroup
    

    instead of using...

    from vkbottle_types import BaseStateGroup
    

    A deprecation warning exists to indicate that in future versions one or more functionalities will be removed or moved to other categories