Answer the question
In order to leave comments, you need to log in
How to stop the cycle by sending a message to VK?
I have code:
from vk_api import VkApi
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id
print("Работает")
vk_session = VkApi(token='токен')
long_poll = VkBotLongPoll(vk_session, 'айди сообщества')
vk = vk_session.get_api()
def autosend(spam):
for i in range(int(spam) + 1):
vk.messages.send(peer_id=peer_id, message=str(i), random_id=get_random_id())
for event in long_poll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
peer_id = event.obj['peer_id']
message = event.obj['text'].lower()
if message.startswith('autosend'):
intspam = message[9:]
autosend(intspam)
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