C
C
Cat_from_russia2020-08-10 15:32:39
Python
Cat_from_russia, 2020-08-10 15:32:39

Keyboard error?

Tell me where the error is in the structure.

import vk_api 
import time 
import random 
from vk_api.keybord import VkKeyboard, VkKeyboardColor 
 
token = "тут был токен" 
 
vk = vk_api.VkApi(token=token) 
 
vk._auth_token() 
 
keyboard = VkKeyboard(one_time=True) 
keyboard.add_button('Белая кнопка', color=VkKeyboardColor.DEFAULT) 
keyboard.add_button('Зелёная кнопка', color=VkKeyboardColor.POSIT) 
 
while True: 
 try: 
 messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"}) 
 if messages["count"] >= 1: 
 id = messages["items"][0]["last_message"]["from_id"] 
 body = messages["items"][0]["last_message"]["text"] 

 if body.lower() == "начать": 
 vk.method("messages.send", {"peer_id": id, "message": "1", "random_id": random.randint(1, 2147483647), "keybord" = keybord}) 
 
 except Exception as E: 
 time.sleep(1)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat_from_russia, 2020-08-11
@Cat_from_russia

Issue resolved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question