This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/handlers/welcome.py

43 lines
2.2 KiB
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from app import app
from pyrogram import filters
2022-12-27 14:36:54 +02:00
from pyrogram.types import ForceReply, ReplyKeyboardMarkup, Message
from pyrogram.client import Client
2023-01-03 14:04:38 +02:00
from classes.holo_user import HoloUser
2022-12-17 01:58:33 +02:00
from modules.utils import all_locales, locale, logWrite
2023-01-03 21:34:13 +02:00
from modules import custom_filters
2022-12-05 19:49:51 +02:00
# Welcome check ================================================================================================================
2022-12-17 01:58:33 +02:00
welcome_1 = []
for pattern in all_locales("welcome", "keyboard"):
welcome_1.append(pattern[0][0])
for pattern in all_locales("return", "keyboard"):
welcome_1.append(pattern[0][0])
2023-01-03 21:34:13 +02:00
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(welcome_1, prefixes=[""]))
2023-01-03 14:04:38 +02:00
async def welcome_pass(app: Client, msg: Message, once_again: bool = True) -> None:
2022-12-05 19:49:51 +02:00
"""Set user's stage to 1 and start a fresh application
### Args:
* app (app): Pyrogram Client to use
* msg (Message): Message with .from_user.id attribute equal to the end-user ID whose application will be started
* once_again (bool, optional): Set to False if it's the first time as user applies. Defaults to True.
"""
if not once_again:
await msg.reply_text(locale("privacy_notice", "message"))
2023-01-03 14:04:38 +02:00
holo_user = HoloUser(msg.from_user)
holo_user.application_restart()
2022-12-05 19:49:51 +02:00
logWrite(f"User {msg.from_user.id} confirmed starting the application")
2022-12-17 01:58:33 +02:00
await msg.reply_text(locale("question1", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("question1", "force_reply", locale=msg.from_user)))
2022-12-05 19:49:51 +02:00
2022-12-17 01:58:33 +02:00
welcome_2 = []
for pattern in all_locales("welcome", "keyboard"):
welcome_2.append(pattern[1][0])
2023-01-03 21:34:13 +02:00
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(welcome_2, prefixes=[""]))
2022-12-27 14:36:54 +02:00
async def welcome_reject(app: Client, msg: Message):
2022-12-05 19:49:51 +02:00
2022-12-15 14:50:11 +02:00
logWrite(f"User {msg.from_user.id} rejected to start the application")
2022-12-17 01:58:33 +02:00
await msg.reply_text(locale("goodbye", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard", locale=msg.from_user), resize_keyboard=True))
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================