S
S
Sergey Kolesnik2022-03-21 06:43:56
Python
Sergey Kolesnik, 2022-03-21 06:43:56

How to collect ID numbers in a telegram bot?

Created a cart bot and wanted to know how many people are using it.

@bot.message_handler(commands=['start'])
def start(message):
    user_id = message.from_user.id
    with open ('id.txt', 'a') as file:
        file.write(f'ID:{user_id}\n')

I made such a design, the bot writes new IDs well from the computer, but how to organize this topic on Heroku in conjunction with the github, the id.txt file is not created in the repository, I created it myself, but no changes are made there (no new ID numbers are added).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gnifajio, 2022-03-23
@gnifajio

As far as I understand, the problem is that on heroku, a separate Dino is created for each user, and they do not have shared files. Try using an external database.

M
Maxim Kravchuk, 2022-03-29
@MaxKra1985

Another option - for each /start send a message to the admin (yourself) with the hashtag #registration. And then you just count the number of messages. )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question