mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
"Этот бот создан с помощью...." возможность выключать в промо
This commit is contained in:
parent
7e016a0eb2
commit
ff28f5cea5
@ -80,3 +80,9 @@ async def threads(bot: Bot, call: types.CallbackQuery):
|
||||
async def additional_info(bot: Bot, call: types.CallbackQuery):
|
||||
bot.enable_additional_info = not bot.enable_additional_info
|
||||
await bot.save(update_fields=["enable_additional_info"])
|
||||
|
||||
|
||||
async def olgram_text(bot: Bot, call: types.CallbackQuery):
|
||||
if await bot.is_promo():
|
||||
bot.enable_olgram_text = not bot.enable_olgram_text
|
||||
await bot.save(update_fields=["enable_olgram_text"])
|
||||
|
@ -162,6 +162,14 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery):
|
||||
callback_data=menu_callback.new(level=3, bot_id=bot.id, operation="additional_info",
|
||||
chat=empty))
|
||||
)
|
||||
is_promo = await bot.is_promo()
|
||||
if is_promo:
|
||||
keyboard.insert(
|
||||
types.InlineKeyboardButton(text=_("Olgram подпись"),
|
||||
callback_data=menu_callback.new(level=3, bot_id=bot.id, operation="olgram_text",
|
||||
chat=empty))
|
||||
)
|
||||
|
||||
keyboard.insert(
|
||||
types.InlineKeyboardButton(text=_("<< Назад"),
|
||||
callback_data=menu_callback.new(level=1, bot_id=bot.id, operation=empty,
|
||||
@ -174,6 +182,11 @@ async def send_bot_settings_menu(bot: Bot, call: types.CallbackQuery):
|
||||
<a href="https://olgram.readthedocs.io/ru/latest/options.html#threads">Потоки сообщений</a>: <b>{0}</b>
|
||||
<a href="https://olgram.readthedocs.io/ru/latest/options.html#user-info">Данные пользователя</a>: <b>{1}</b>
|
||||
""")).format(thread_turn, info_turn)
|
||||
|
||||
if is_promo:
|
||||
olgram_turn = _("включена") if bot.enable_olgram_text else _("выключена")
|
||||
text += _("Olgram подпись: {0}").format(olgram_turn)
|
||||
|
||||
await edit_or_create(call, text, reply_markup=keyboard, parse_mode="HTML")
|
||||
|
||||
|
||||
|
4
olgram/migrations/models/13_20220409051838_update.sql
Normal file
4
olgram/migrations/models/13_20220409051838_update.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- upgrade --
|
||||
ALTER TABLE "bot" ADD "enable_olgram_text" BOOL NOT NULL DEFAULT True;
|
||||
-- downgrade --
|
||||
ALTER TABLE "bot" DROP COLUMN "enable_olgram_text";
|
@ -44,6 +44,7 @@ class Bot(Model):
|
||||
|
||||
enable_threads = fields.BooleanField(default=False)
|
||||
enable_additional_info = fields.BooleanField(default=False)
|
||||
enable_olgram_text = fields.BooleanField(default=True)
|
||||
|
||||
def decrypted_token(self):
|
||||
cryptor = DatabaseSettings.cryptor()
|
||||
@ -60,6 +61,10 @@ class Bot(Model):
|
||||
return group_chat.chat_id
|
||||
return (await self.owner).telegram_id
|
||||
|
||||
async def is_promo(self):
|
||||
owner = await self.fetch_related("owner")
|
||||
return await owner.is_promo()
|
||||
|
||||
class Meta:
|
||||
table = 'bot'
|
||||
|
||||
|
@ -171,8 +171,10 @@ async def message_handler(message: types.Message, *args, **kwargs):
|
||||
|
||||
if message.text and message.text == "/start":
|
||||
# На команду start нужно ответить, не пересылая сообщение никуда
|
||||
return SendMessage(chat_id=message.chat.id,
|
||||
text=bot.start_text + _(ServerSettings.append_text()))
|
||||
text = bot.start_text
|
||||
if bot.enable_olgram_text:
|
||||
text += _(ServerSettings.append_text())
|
||||
return SendMessage(chat_id=message.chat.id, text=text)
|
||||
|
||||
if message.text and message.text == "/security_policy":
|
||||
# На команду security_policy нужно ответить, не пересылая сообщение никуда
|
||||
|
Loading…
Reference in New Issue
Block a user