Answer the question
In order to leave comments, you need to log in
How to write a keyboard for a bot on vk_api?
There is a chatbot code on vk_api and a regular longpoll.
It is necessary to add a keyboard to the code so that it sends it to the chat when commanded.
Full kettle.
import sys
sys.path.insert(0, "../")
import sqlite3
import random
import vk_api
import time
import datetime
import pytz
from vk_api.longpoll import VkLongPoll, VkEventType
from random import randint
from random import choice
from datetime import datetime
token = "TOKEN"
vk_session = vk_api.VkApi(token=token)
session_api = vk_session.get_api()
longpoll = VkLongPoll(vk_session)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
response = event.text.lower()
if event.from_user and not (event.from_me):
if response == "привет":
vk_session.method('messages.send', {'user_id': event.user_id, 'message': "Алоэ", 'random_id': 0})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question