Answer the question
In order to leave comments, you need to log in
How to make a VK bot reply only to a specific person?
Hello, how can I make the bot be distracted only by my message?
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
vk_session = vk_api.VkApi(token='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:
response = event.text.lower()
if response == "пинг":
time.sleep(3)
send_msg(event.peer_id, "PONG")
except Exception as e:
print(repr(e))
Answer the question
In order to leave comments, you need to log in
response = event.text.lower
if response == "пинг" and peer_id == ваш_id:
send_msg()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question