A
A
andreysyomin2020-04-25 01:20:28
Python
andreysyomin, 2020-04-25 01:20:28

How to forward a message \ reply to a user in Vk via longpool?

I just started to master the VK longpool (I didn’t really find the answer in the documentation) and python. Code actually:

from vk_api.longpoll import VkLongPoll, VkEventType
import vk_api, random
from datetime import datetime
import random
login, password = "Логин", "Пароль"

vk_session = vk_api.VkApi(login=login, password=password, app_id=2685278)
vk_session.auth(token_only=True)


session_api = vk_session.get_api()

longpoll = VkLongPoll(vk_session)

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)
for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW:
        print('Текст сообщения: ' + str(event.text))
        response = event.text.lower()
        if response =='баф899':
            send_message(peer_id=event.peer_id,message='Благословение атаки')

I want to answer like from the picture5ea365ee5a8eb335254864.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-25
@Makaroshka007

https://vk.com/dev/messages.send

reply_to - ID of the message to which you want to reply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question