Answer the question
In order to leave comments, you need to log in
How to spam vk_api python bot?
The task is this -
So that when writing a message, the bot starts spamming in PM, if a person writes stop, the bot will stop, I implemented almost everything, but I don’t know how to implement it so that the bot does not answer 1 time in PM, but endlessly ..
Please help, here is the code ->
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
import vk
import random
import time
print('Бот успешно запущен!')
vk = vk_api.VkApi(token="Тут мой token")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk,Тут id моей группы)
while True:
try:
messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"})
if messages["count"] >= 1:
id = messages["items"][0]["last_message"]["from_id"]
body = messages["items"][0]["last_message"]["text"]
if body.lower() == "начать спам":
vk.method("messages.send", {"peer_id": id, "message": "‼Разрешите спамить вам в лс, пропишите разрешаю‼", "random_id": random.randint(1, 2147483647)})
elif body.lower() == "разрешаю":
vk.method("messages.send", {"peer_id": id,"message": "✉Спам сообщение✉\nЧтобы остановить спам пропишите стоп","random_id": random.randint(1,5346262462742722)})
elif body.lower() == "стоп":
vk.method("messages.send", {"peer_id": id, "message": "✨Спам сообщениями остановлен✨\nЕсли хотите опять начать спам сообщениями пропишите начать спам", "random_id": random.randint(1, 2147483647)})
except Exception as E:
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