Answer the question
In order to leave comments, you need to log in
How to create a bot for a VK page in python?
Hello everyone, how to create a bot for a VK page in python. Looked everywhere for nothing. Help
Answer the question
In order to leave comments, you need to log in
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
vk_session = vk_api.VkApi(token='токен')
longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()
def send_msg(peer_id: int, message: str, attachment: str = ""):
return vk.messages.send( **locals(), random_id=0)
while True:
try:
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.text == "привет":
send_msg(event.peer_id, "Привет")
except Exception as e:
print(repr(e))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question