J
J
Josh Rubanhof2020-12-16 12:36:15
Python
Josh Rubanhof, 2020-12-16 12:36:15

How to send blank keyboard to VK API?

Liba: vk-api v11.9.1

Code:

"""
инициализация библиотеки vk_api
...
"""
 empty_keyboard = {
        "one_time": False,
        "buttons": []
    }

    for event in longpoll.listen():
        if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
            if event.text == 'Clear':
                if event.from_user:
                    vk.messages.send(
                        user_id = event.user_id,
                        keyboard = empty_keyboard,
                        message = "Пустая клавиатура",
                        random_id = get_random_id()
                    )


Input: Clear

Output:
Traceback (most recent call last):
  File "C:\Users\1\Desktop\python bots\vk-hw-bot\bot.py", line 68, in <module>
    main()
  File "C:\Users\1\Desktop\python bots\vk-hw-bot\bot.py", line 38, in main
    vk.messages.send(
  File "C:\Users\1\Desktop\python bots\vk-hw-bot\venv\lib\site-packages\vk_api\vk_api.py", line 696, in __call__
    return self._vk.method(self._method, kwargs)
  File "C:\Users\1\Desktop\python bots\vk-hw-bot\venv\lib\site-packages\vk_api\vk_api.py", line 656, in method
    raise error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: keyboard contains incorrect JSON


Question: How can I correctly set the parameters for `empty_keyboard` so that the above error does not occur? Thank you in advance for your response.

p.s. Already looked at answers both on Stackoverflow and Habr, however none of them solved my problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dev12345, 2020-12-16
@Dev12345

Send an empty keyboard, I think it will not work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question