возможность отзывать токен

This commit is contained in:
mihalin 2022-04-09 06:10:48 +03:00
parent e78b0c1150
commit 1c4ce35829
2 changed files with 28 additions and 1 deletions

View File

@ -185,7 +185,7 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery):
if is_promo: if is_promo:
olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена") olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена")
text += _("Olgram подпись: {0}").format(olgram_turn) text += _("Olgram подпись: <b>{0}</b>").format(olgram_turn)
await edit_or_create(call, text, reply_markup=keyboard, parse_mode="HTML") 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": if operation == "additional_info":
await bot_actions.additional_info(bot, call) await bot_actions.additional_info(bot, call)
return await send_bot_settings_menu(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": if operation == "reset_text":
await bot_actions.reset_bot_text(bot, call) await bot_actions.reset_bot_text(bot, call)
return await send_bot_text_menu(bot, call) return await send_bot_text_menu(bot, call)

View File

@ -29,6 +29,30 @@ async def new_promo(message: types.Message, state: FSMContext):
await promo.save() 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="*") @dp.message_handler(commands=["setpromo"], state="*")
async def set_promo(message: types.Message, state: FSMContext): async def set_promo(message: types.Message, state: FSMContext):
""" """