M
M
mrisid2019-08-30 08:16:53
Python
mrisid, 2019-08-30 08:16:53

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

1 answer(s)
Y
Yuri, 2019-08-30
@riky

all methods from the messages.* section are closed to the general public as of February 2019.
so the code won't work anyway.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question