Answer the question
In order to leave comments, you need to log in
How to make a VK bot on vk_api answer several people at the same time?
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
import random
def write_msg(user_id,message,rand_int):
vk.method('messages.send',{'user_id':user_id,'message':message,'random_id':rand_int})
vk=vk_api.VkApi(token=token)
longpoll=VkLongPoll(vk)
while True:
for event in longpoll.listen():
if event.type==VkEventType.MESSAGE_NEW:
if event.to_me:
rand=random.randint(10000000,90000000)
request=event.text
if request=='Привет':
write_msg(event.user_id,'Привет. ',rand)
elif request=='Пока':
write_msg(event.user_id,'Пока',rand)
else:
write_msg(event.user_id,'Не понял?',rand)
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