ohld / django-telegram-bot

My sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template
https://t.me/ffmemesbot
Apache License 2.0
682 stars 170 forks source link

bot always answers "Welcome back", even for new users #19

Closed rayman1104 closed 2 years ago

rayman1104 commented 3 years ago

Hi, found a small bug. Must be uppeared after resolving https://github.com/ohld/django-telegram-bot/issues/16 🙂

Steps to reproduce:

  1. Start local setup via docker-compose.
  2. Send /start from a new device that is not yet in DB.
  3. You'll get message "Welcome back, {first_name}!" instead of "Sup, {first_name}!"

The reason: Method User.get_user_and_created is called twice for /start command: first in handler_logging function, second in command_start. On the second call created is always false, so the message is always "Welcome back".

Possible solution: In handler_logging call func first, and then do the actual logging part.