F
F
From Prog2021-06-14 18:13:59
Python
From Prog, 2021-06-14 18:13:59

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

It doesn't work like that, I have no other ideas.

I would like the counter to be updated every time the user enters the bot, and not write the / start command

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZykaMyzyka, 2021-06-14
@ZykaMyzyka

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 question

Ask a Question

731 491 924 answers to any question