A
A
AndreZhukov2020-07-12 12:50:42
Python
AndreZhukov, 2020-07-12 12:50:42

How to make a referral system in a bot?

Hello. I use the following code for the referral system in the bot:

ref_id = message.text.split("?start=")[1]  # получаем id реферала
print(ref_id)
if ref_id != usr_id[user_id]:
    query = "INSERT INTO refers_neural (`usr_id`, `ref_ids`) VALUES (%s, %s);"
    cursor = connect.cursor()
    cursor.execute(query, (usr_id[user_id], ref_id))
    query_two = "UPDATE users_neural SET invited = invited + 1 WHERE usr_id = %s"
    curs = connect.cursor()
    curs.execute(query_two, usr_id[user_id])
    connect.commit()
    print(ref_id)


first i get an error
IndexError: list index out of range

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question