I
I
Igor_Merg2021-02-23 10:49:48
Python
Igor_Merg, 2021-02-23 10:49:48

How to make the bot repost new posts from the VK group?

At the moment I am writing my "Chat Manager" for a conversation and a group in general, I need help with reposts in a conversation.
I found the code on another forum, but it does not do what I would like.

if event_chat.type == VkBotEventType.WALL_POST_NEW:
        id_ = event_chat.object['id']
        owner_id_ = event_chat.group_id
        wall_id = f'wall-{owner_id_}_{id_}'
        write_chat(id2,'vk.com/botcoled?w={}'.format(wall_id))

As a result, the bot sends only this.
-QAo9z6ANPE.jpg?size=136x48&quality=96&proxy=1&sign=3b3bafabc631014e9b6971572dbab003&type=album
But this is not a repost, you can do it, of course, type a link to a new post, but this is not it.
I would like the bot to repost like this:
F28KVBSIt3o.jpg?size=483x192&quality=96&proxy=1&sign=c923089dc7772d34b5d72e4032177bdb&type=album

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-02-23
@Igor_Merg

You need to call the method messages.send, passing a parameter attachmentwith a value in the form of the necessary attachments in the format <type><owner_id>_<media_id>separated by commas.
I don’t know what is in the write_chat function and I won’t guess, therefore

if event_chat.type == VkBotEventType.WALL_POST_NEW:
    id_ = event_chat.object['id']
    owner_id_ = event_chat.group_id
    wall_post = f'wall-{owner_id_}_{id_}'
    vk.method('messages.send', {'peer_id': id2, 'message': 'Новый пост в группе', 'attachment': wall_post})

https://vk.com/dev/messages.send
ps: _after owner_idthat you can not put

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question