diff --git a/classes/holo_user.py b/classes/holo_user.py index 766e2ff..f10f3ff 100644 --- a/classes/holo_user.py +++ b/classes/holo_user.py @@ -351,6 +351,10 @@ class HoloUser(): progress = col_tmp.find_one({"user": self.id, "type": "application"}) stage = progress["stage"] + + if self.sponsorship_state()[0] == "fill": + await msg.reply_text(locale("finish_sponsorship", "message"), quote=should_quote(msg)) + return if progress["state"] == "fill" and progress["sent"] is False: diff --git a/locale/uk.json b/locale/uk.json index ecbea7e..9178313 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -90,6 +90,8 @@ "sponsorships_expires": "⚠️ **Нагадування**\nНадана платна підписка припинить діяти **за {0} д**. Будь ласка, оновіть дані про неї командою /sponsorship інакше роль буде втрачено!", "sponsorships_expired": "⚠️ **Нагадування**\nТермін дії вказаної підписки сплив. Для повторного отримання ролі користуйся командою /sponsorship.", "label_too_long": "Довжина назви ролі не повинна перевищувати 16 символів", + "finish_sponsorship": "❌ **Дія неможлива**\nПерш ніж заповнювати анкету, треба завершити заповнення форми спонсора.", + "finish_application": "❌ **Дія неможлива**\nПерш ніж заповнювати форму спонсора, треба завершити заповнення анкети.", "voice_message": [ "why are u gae", "руки відірвало? пиши як людина", diff --git a/modules/callbacks/reapply.py b/modules/callbacks/reapply.py index 185467a..e75a529 100644 --- a/modules/callbacks/reapply.py +++ b/modules/callbacks/reapply.py @@ -3,7 +3,7 @@ from app import app from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardRemove from pyrogram import filters from classes.holo_user import HoloUser -from modules.utils import configGet, locale, logWrite +from modules.utils import configGet, locale, logWrite, should_quote from modules.handlers.confirmation import confirm_yes from modules.handlers.welcome import welcome_pass from modules.database import col_tmp, col_applications @@ -76,6 +76,11 @@ async def callback_query_reapply_reject(app, clb): @app.on_callback_query(filters.regex("reapply_old_[\s\S]*")) async def callback_query_reapply_old(app, clb): fullclb = clb.data.split("_") + + if HoloUser(clb.from_user).sponsorship_state()[0] == "fill": + await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)) + return + message = await app.get_messages(clb.from_user.id, int(fullclb[2])) await confirm_yes(app, message, kind="application") await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button", locale=clb.from_user), "nothing")]])) @@ -86,6 +91,10 @@ async def callback_query_reapply_new(app, clb): fullclb = clb.data.split("_") + if HoloUser(clb.from_user).sponsorship_state()[0] == "fill": + await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)) + return + await clb.answer(locale("reapply_stopped", "callback", locale=clb.from_user)) message = await app.get_messages(clb.from_user.id, int(fullclb[2])) col_tmp.update_one({"user": clb.from_user.id}, {"$set": {"state": "fill", "completed": False, "stage": 1}}) diff --git a/modules/callbacks/sponsorship.py b/modules/callbacks/sponsorship.py index 6b2fdd4..584459b 100644 --- a/modules/callbacks/sponsorship.py +++ b/modules/callbacks/sponsorship.py @@ -1,18 +1,23 @@ from datetime import datetime from app import app -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, CallbackQuery +from pyrogram.client import Client from pyrogram import filters from classes.holo_user import HoloUser -from modules.utils import configGet, locale, logWrite +from modules.utils import configGet, locale, logWrite, should_quote from modules.database import col_tmp, col_sponsorships # Callbacks sponsorship ======================================================================================================== @app.on_callback_query(filters.regex("sponsor_apply_[\s\S]*")) -async def callback_query_sponsor_apply(app, clb): +async def callback_query_sponsor_apply(app: Client, clb: CallbackQuery): fullclb = clb.data.split("_") holo_user = HoloUser(int(fullclb[2])) + if holo_user.application_state()[0] == "fill": + await clb.message.reply_text(locale("finish_application", "message"), quote=should_quote(clb.message)) + return + logWrite(f"User {holo_user.id} applied for sponsorship") holo_user.sponsorship_restart() diff --git a/modules/commands/reapply.py b/modules/commands/reapply.py index 635b3ca..92d0c02 100644 --- a/modules/commands/reapply.py +++ b/modules/commands/reapply.py @@ -2,7 +2,7 @@ from app import app from pyrogram import filters from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton from classes.holo_user import HoloUser -from modules.utils import configGet, locale +from modules.utils import configGet, locale, should_quote from modules.handlers.welcome import welcome_pass from modules.database import col_tmp @@ -19,6 +19,9 @@ async def cmd_reapply(app, msg): if member.user.id == msg.from_user.id: left_chat = False if not left_chat: + if holo_user.sponsorship_state()[0] == "fill": + await msg.reply_text(locale("finish_sponsorship", "message"), quote=should_quote(msg)) + return holo_user.application_restart(reapply=True) await welcome_pass(app, msg, once_again=True) else: diff --git a/modules/commands/sponsorship.py b/modules/commands/sponsorship.py index 930f93f..9efb263 100644 --- a/modules/commands/sponsorship.py +++ b/modules/commands/sponsorship.py @@ -1,6 +1,7 @@ from app import app, isAnAdmin from pyrogram import filters from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton +from classes.holo_user import HoloUser from modules.utils import locale, should_quote from modules.database import col_applications @@ -8,6 +9,9 @@ from modules.database import col_applications @app.on_message(~ filters.scheduled & filters.command(["sponsorship"], prefixes=["/"])) async def cmd_sponsorship(app, msg): if (await isAnAdmin(msg) is True) or (col_applications.find_one({"user": msg.from_user.id}) is not None): + if HoloUser(msg.from_user).application_state()[0] == "fill": + await msg.reply_text(locale("finish_application", "message"), quote=should_quote(msg)) + return await msg.reply_text(locale("sponsorship_apply", "message"), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text=str(locale("sponsor_apply", "button")), callback_data=f"sponsor_apply_{msg.from_user.id}")]]), quote=should_quote(msg)) else: await msg.reply_text(locale("sponsorship_application_empty", "message"))