A
A
Alexey Dagaev2019-09-12 21:19:43
Layout
Alexey Dagaev, 2019-09-12 21:19:43

[vk_api] Why does LongPoll not respond to a message with a large number of attachments?

Hello. I made a bot that, when sending attachments to it, sent a post to the group.
At first, everything worked well, the posts were sent, but not the point. The fact is that when I tried to send 8-10 photos, the server did not send me events at all.
Help me figure out what's wrong? What api doesn't have this problem? Help.

from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api, random, time
import utils

import traceback

token = "token"
group_id = 'group_id'
#peers
vk_session = vk_api.VkApi(token=token)
session_api = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, group_id)
def send_message(peer_id, message=None, attachment=None, keyboard=None, payload=None):
    session_api.messages.send(peer_id=peer_id, message=message, random_id=random.randint(-2147483648, +2147483648),
                              attachment=attachment, keyboard=keyboard, payload=payload)
print('ready')
while True:
    for event in longpoll.listen():
        print(event)
        if event.type.name == 'MESSAGE_NEW':
            if not event.obj.from_me:
                response = event.obj.text.lower()
                attachments = event.obj.attachments
                print(attachments)
                if attachments:
                    photos = []
                    print(attachments)
                    for tmp in attachments:

                        print(tmp)
                        a1 = str(tmp['type'])
                        a2 = str(tmp['photo']['owner_id'])
                        a3 = str(tmp['photo']['id'])
                        try:
                            a4 = '_'+str(tmp['photo']['access_key'])
                        except:
                            a4 = ''
                        attachment = a1 +a2 +'_'+ a3 + a4
                        print(attachment)
                        photos.append(attachment)
                        photo = ','.join(photos)
                        print(photo)
                    message = 'd'
                    attachment = photo
                    utils.wall_post(attachments=attachment)
                    send_message(peer_id=event.obj.peer_id,message=message,attachment=attachment)



                else:
                    print('aaaaa')

#utils.py
import random, vk_api
import time


vk_session = vk_api.VkApi(token='user_token')
session_api = vk_session.get_api()

group_id = 'group_id'

def wall_post(owner_id=group_id,from_group=1,message='Успех',attachments='photo486197227_457252942_893690535b5577dc43',publish_date=(time.time())+400):
    session_api.wall.post(owner_id=owner_id,from_group=from_group,message=message,attachments=attachments,publish_date=publish_date)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Brake Made, 2018-04-06
@DanilAndreevich

in fact, these are two blocks, on one color
on the other background
, and on top of all this, there is an empty block with border
and it seems that I have already seen this question here

A
Alexander, 2018-04-06
@pi4yyy

I had the same question not so long ago, you can see the answers there
How to implement a similar effect?

S
sharkyyy3, 2019-09-12
@sharkyyy3

Hello, I'm facing the same problem. Wrote in those. VK support is what they answered:
https://yadi.sk/i/4GFov7Eb4R-67g

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question