File size: 1,444 Bytes
16bfc87 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import datetime
from django.utils import timezone
from telegram import ParseMode, Update
from telegram.ext import CallbackContext
from tgbot.handlers.onboarding import static_text
from tgbot.handlers.utils.info import extract_user_data_from_update
from users.models import User
from tgbot.handlers.onboarding.keyboards import make_keyboard_for_start_command
def command_start(update: Update, context: CallbackContext) -> None:
u, created = User.get_user_and_created(update, context)
if created:
text = static_text.start_created.format(first_name=u.first_name)
else:
text = static_text.start_not_created.format(first_name=u.first_name)
update.message.reply_text(text=text,
reply_markup=make_keyboard_for_start_command())
def secret_level(update: Update, context: CallbackContext) -> None:
# callback_data: SECRET_LEVEL_BUTTON variable from manage_data.py
""" Pressed 'secret_level_button_text' after /start command"""
user_id = extract_user_data_from_update(update)['user_id']
text = static_text.unlock_secret_room.format(
user_count=User.objects.count(),
active_24=User.objects.filter(updated_at__gte=timezone.now() - datetime.timedelta(hours=24)).count()
)
context.bot.edit_message_text(
text=text,
chat_id=user_id,
message_id=update.callback_query.message.message_id,
parse_mode=ParseMode.HTML
) |