V
V
vadasovic2019-08-07 13:34:23
Python
vadasovic, 2019-08-07 13:34:23

How to use post_id in vk_api?

I decided to write a bot that will send a newly appeared post to the conference in which it is a member, but for some reason the code below does not work and returns the error "[10] internal server error", although the error points to the server, that's all for me It still looks like I screwed up.

for event in longpoll.listen():
        if event.type == VkBotEventType.WALL_POST_NEW:
            vk.messages.send(chat_id = 1, random_id = random.getrandbits(64),
                        message = 'Новый пост в сообществе: ',
                        attachment = event.obj.post_id)

In addition to this question, I would like to know how to make the bot send this message to all the conversations in which it is a member?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-08-07
@StockholmSyndrome

attachment should look like this: wall<owner_id>_<post_id>where owner_id is the community ID

how to make the bot send this message to all conversations in which it is a member?
you can try incrementing the chat_id until you get an error saying the conversation doesn't exist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question