Answer the question
In order to leave comments, you need to log in
How in the TG bot to make it so that every time a user starts the bot, the user count variable increases by 1?
The code:
@my_bot.message_handler(commands = ['start'])
def welcome(message):
global number
number = 0
my_bot.send_message(message.chat.id, f'Вы, {number} пользователь этого бота!\n\nПривет, {message.from_user.first_name})
global number
number += 1
Answer the question
In order to leave comments, you need to log in
Look, in general it is necessary to create .
In a text document, you enter the Id of users, at the beginning you can write down the counter (in the first line) which is useful for mailing lists, subscriptions and other chips. It's better to do it right away in a file)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question