W
W
winniuss2020-02-03 16:52:11
Python
winniuss, 2020-02-03 16:52:11

How to do a quick mailing of messages in the VK community?

I have a bot in the VK community, I have implemented the notification function. It works through the shelve library

import shelve
with shelve.open('notifies/users') as shlv:
    users = list(shlv.items())
for k in range(len(users)):
    if users[k][1] == '1':
        vk.messages.send(peer_id=str(users[k][0]), random_id=random.getrandbits(32), message='уведомление')

That is, the database contains records of the form [('485062400', '1'), ('485062401', '0'), ('485062402', '1'), ('485062403', '1')], where first VK_ID, and then 0 if notifications are disabled.

Essence of the question
It took 291 seconds to send notifications to 481 people. All this time, the bot is busy sending and ignoring incoming messages until it is released. I checked that the condition on / off notice. does not add time. How to do instant mailing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2020-02-03
@winniuss

user_ids up to 100 users per call

T
Taus, 2020-02-03
@Taus

No, there are restrictions on the same type of requests in order to prevent spam.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question