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)