Answer the question
In order to leave comments, you need to log in
How to make the bot react only to the commands of a certain person?
import vk_api
import time
import codecs
vk = vk_api.VkApi(login = 'log', password='pass')
vk.auth()
while True:
messages = vk.method('messages.getConversations', {'offset': 0, "count": 20, 'filter': 'unread'})
if messages["count"] >= 1:
id = messages['items'][0]['last_message']["from_id"]
body = messages["items"][0]['last_message']['text']
if body.lower() == "!crush":
for i in range(10):
file = open('f.txt')
f = file.read()
vk.method('messages.send', {'peer_id': id, 'message': f})
file.close()
elif body.lower() == "...":
vk.method('messages.send', {'peer_id': id, 'message': "..."})
else:
vk.method('messages.send', {'peer_id': id, 'message': "text"})
time.sleep(1)
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