S
S
samperirrrrr2020-12-11 13:02:00
Python
samperirrrrr, 2020-12-11 13:02:00

Why doesn't the bot respond to buttons in a Python conversation?

Hello everyone, help. My bot does not respond to buttons only in conversations, everything is ok in PM. Here is below code

keyboard = VkKeyboard(one_time=False, inline=True)
keyboard.add_button('/reg', color=VkKeyboardColor.NEGATIVE)
keyboard.add_button('мда', color=VkKeyboardColor.POSITIVE)
if responce == "клава":
         vk.messages.send(peer_id=id,random_id=0,message="panos",keyboard=keyboard.get_keyboard())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dr0st, 2020-12-11
@samperirrrrr

Good day, I had the same problem, I found the solution like this:

msg = event.text
msg = msg.replace('[club<b>id группы</b>|@<b>домен группы</b>] ', '')
msg = msg.replace('[club<b>id группы</b>|<b>название группы</b>] ', '')

How I created the keyboard itself:
keyboard.add_button('text', color=VkKeyboardColor.DEFAULT)
                    vk.messages.send(
                        peer_id=event.peer_id,
                        random_id=get_random_id(),
                        keyboard=keyboard.get_keyboard(),
                        message='text2'
                    )

To use get_random_id() (a handy thing by the way), you need to import the following:from vk_api.utils import get_random_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question