K
K
Kendric Folkin2021-01-29 16:03:45
Python
Kendric Folkin, 2021-01-29 16:03:45

Is it possible to make a function be called when a button is pressed in VK?

Is it possible to make a function be called when a button is pressed in VK?

keyboard.add_button(label='1', color=VkKeyboardColor.SECONDARY)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bitkoljas, 2021-01-31
@bitkoljas

If I'm not mistaken, then the button in VK cannot call the function, it only sends an SMS with the text that is written in it, this is done to speed up the work
. And the function can already be performed when you read the text of the SMS and compare it with the function
For example: You have in the chat the button with the text TextText, when you press it, the text will be sent to the chat: TestText, then the bot receives the text of the sent SMS and, through the condition, will call the function

def Test():
    print("Вы нажали кнопку: TestText")
if body == "TestText":
    Test()
#body - переменная где хранится текст считаной из чата смс

If I'm wrong about something, please correct me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question