From 1c4ce358294049a7adcb56c6d6847d471ccb84ab Mon Sep 17 00:00:00 2001 From: mihalin Date: Sat, 9 Apr 2022 06:10:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=B7=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- olgram/commands/menu.py | 5 ++++- olgram/commands/promo.py | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/olgram/commands/menu.py b/olgram/commands/menu.py index 3a76fc2..c359e10 100644 --- a/olgram/commands/menu.py +++ b/olgram/commands/menu.py @@ -185,7 +185,7 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery): if is_promo: olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена") - text += _("Olgram подпись: {0}").format(olgram_turn) + text += _("Olgram подпись: {0}").format(olgram_turn) await edit_or_create(call, text, reply_markup=keyboard, parse_mode="HTML") @@ -428,6 +428,9 @@ async def callback(call: types.CallbackQuery, callback_data: dict, state: FSMCon if operation == "additional_info": await bot_actions.additional_info(bot, call) return await send_bot_settings_menu(bot, call) + if operation == "olgram_text": + await bot_actions.olgram_text(bot, call) + return await send_bot_settings_menu(bot, call) if operation == "reset_text": await bot_actions.reset_bot_text(bot, call) return await send_bot_text_menu(bot, call) diff --git a/olgram/commands/promo.py b/olgram/commands/promo.py index 0ab6c5c..1e6dd6a 100644 --- a/olgram/commands/promo.py +++ b/olgram/commands/promo.py @@ -29,6 +29,30 @@ async def new_promo(message: types.Message, state: FSMContext): await promo.save() +@dp.message_handler(commands=["delpromo"], state="*") +async def del_promo(message: types.Message, state: FSMContext): + """ + Команда /delpromo + """ + + if message.chat.id != OlgramSettings.supervisor_id(): + await message.answer(_("Недостаточно прав")) + return + + try: + uuid = UUID(message.get_args().strip()) + promo = await models.Promo.get_or_none(code=uuid) + except ValueError: + return await message.answer(_("Неправильный токен")) + + if not promo: + return await message.answer(_("Такого кода не существует")) + + await promo.delete() + + await message.answer(_("Промокод отозван")) + + @dp.message_handler(commands=["setpromo"], state="*") async def set_promo(message: types.Message, state: FSMContext): """