R
R
romka123982020-09-11 11:33:51
Python
romka12398, 2020-09-11 11:33:51

Bot for VK. What should be added so that the bot writes messages to the conversation?

Help with a python lot In
short, I need to add a part to the bot in which he can answer in a VK conversation bot
Here and in the patebine: https://pastebin.com/umEmBm5W

import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType

vk_session = vk_api. VkApi(token = token)
session_api = vk_session.get_api()
longpol = VkLongPoll(vk_session)

def sender(id,text):
vk_session.method('messages.send', { 'user_id' : id, 'message' : text, 'random_id' : 0 } )

for event in longpol.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = event.text.lower()
id = event.user_id
if msg == ' hello':
sender(id,'Healthy')
elif msg == 'how are you?':
sender(id, 'Normal

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question