From 59dafc004da7c8d9d7606eee4133b4218fc6fb8d Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Thu, 5 Jan 2023 20:46:47 +0100 Subject: [PATCH] LabelSettingError added --- modules/callbacks/sponsorship.py | 7 +++++-- modules/commands/label.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/callbacks/sponsorship.py b/modules/callbacks/sponsorship.py index 429aa2b..30d5ea1 100644 --- a/modules/callbacks/sponsorship.py +++ b/modules/callbacks/sponsorship.py @@ -3,7 +3,7 @@ from app import app from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, CallbackQuery from pyrogram.client import Client from pyrogram import filters -from classes.holo_user import HoloUser +from classes.holo_user import HoloUser, LabelSettingError from modules.utils import configGet, locale, logWrite, should_quote from modules.database import col_tmp, col_sponsorships @@ -67,7 +67,10 @@ async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery): } ) - await holo_user.label_set(configGet("users", "groups"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"]) + try: + await holo_user.label_set(configGet("users", "groups"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"]) + except LabelSettingError as exp: + await app.send_message(configGet("admin", "groups"), exp.__str__(), disable_notification=True) edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]] diff --git a/modules/commands/label.py b/modules/commands/label.py index e0e711e..f669489 100644 --- a/modules/commands/label.py +++ b/modules/commands/label.py @@ -2,8 +2,8 @@ from app import app from pyrogram import filters from pyrogram.types import Message from pyrogram.client import Client -from modules.utils import locale, should_quote, find_user -from classes.holo_user import HoloUser, LabelTooLongError +from modules.utils import configGet, locale, should_quote, find_user +from classes.holo_user import HoloUser, LabelTooLongError, LabelSettingError from modules import custom_filters # Label command ================================================================================================================ @@ -32,6 +32,9 @@ async def cmd_label(app: Client, msg: Message): except LabelTooLongError: await msg.reply_text(locale("label_too_long", "message")) return + except LabelSettingError as exp: + await app.send_message(configGet("admin", "groups"), exp.__str__(), disable_notification=True) + return await msg.reply_text(f"Setting **{target.id}**'s label to **{label}**...", quote=should_quote(msg)) else: