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/commands/reapply.py

48 lines
2.5 KiB
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from app import app
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
2022-12-14 14:58:06 +02:00
from classes.holo_user import HoloUser
from modules.utils import configGet, locale
2022-12-05 19:49:51 +02:00
from modules.handlers.welcome import welcome_pass
2022-12-14 14:58:06 +02:00
from modules.database import col_tmp
2022-12-05 19:49:51 +02:00
# Reapply command ==============================================================================================================
@app.on_message(~ filters.scheduled & filters.private & filters.command(["reapply"], prefixes=["/"]))
async def cmd_reapply(app, msg):
2022-12-14 14:58:06 +02:00
holo_user = HoloUser(msg.from_user)
if holo_user.application_state()[0] in ["approved", "rejected"]:
if (holo_user.application_state()[1] is True) and (not col_tmp.find_one({"user": holo_user.id, "type": "application"})["sent"]):
2022-12-05 19:49:51 +02:00
left_chat = True
async for member in app.get_chat_members(configGet("destination_group")):
if member.user.id == msg.from_user.id:
left_chat = False
if not left_chat:
2022-12-14 14:58:06 +02:00
holo_user.application_restart()
2022-12-05 19:49:51 +02:00
await welcome_pass(app, msg, once_again=True)
else:
await msg.reply_text(locale("reapply_left_chat", "message"), reply_markup=InlineKeyboardMarkup([
[
InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}")
2022-12-05 19:49:51 +02:00
],
[
InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}")
2022-12-05 19:49:51 +02:00
]
]))
else:
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([
2022-12-05 19:49:51 +02:00
[
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}")
2022-12-05 19:49:51 +02:00
]
]))
2022-12-05 19:49:51 +02:00
else:
2022-12-14 14:58:06 +02:00
if (holo_user.application_state()[0] == "fill") and (col_tmp.find_one({"user": holo_user.id, "type": "application"})["sent"] is True):
2022-12-05 19:49:51 +02:00
await msg.reply_text(locale("reapply_forbidden", "message"))
else:
await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([
2022-12-05 19:49:51 +02:00
[
InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}")
2022-12-05 19:49:51 +02:00
]
]))
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================