Выдаёт ошибку:
module 'vk_api' has no attribute 'keyboard'
В этой строчке:
keyboard = vk_api.keyboard.VkKeyboard(one_time=False)
Код:
import random
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
print("Bot started!")
def write_msg(user_id, message):
vk.method('messages.send', {'user_id': user_id, 'message': message, 'random_id':random.randint(1,9999999)})
def create_keyboard():
keyboard = vk_api.keyboard.VkKeyboard(one_time=False)
keyboard.add_button("Привет", color=vk_api.keyboard.VkKeyboardColor.DEFAULT)
return keyboard.get_keyboard()
TOKEN = "скрыл"
vk = vk_api.VkApi(token = TOKEN)
longpoll = VkLongPoll(vk)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
request = event.text
if request == "Привет" or request == "привет":
write_msg(event.user_id, "Хай, бро!")
create_keyboard()
elif request == "Пока" or request == "Пока":
write_msg(event.user_id, "Пока((")
else:
write_msg(event.user_id, "Не понял вашего ответа!")