H
H
Helper2021-04-25 12:46:55
In contact with
Helper, 2021-04-25 12:46:55

How to arrange a referral system in a VK bot in python?

Created links ref and ref_source (ref=id) and I need to check if a person clicked on it. If you went over and wrote the text, then add a referral to the one whose link the person followed. Thanks a lot for your help.
(Library VkApi)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Antonov, 2021-05-03
@xtonypythonx

from vk_api.longpoll import VkLongPoll, VkEventType
import requests
import vk_api

vk_session = vk_api.VkApi(token='токен')

longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()

for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:

        if event.text.lower() == 'реф':
            if event.ref == "тут ид нужного человека":
                vk.messages.send(
                    user_id=event.user_id,
                    message='Ваш текст'
    )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question