diff --git a/olgram/commands/bots.py b/olgram/commands/bots.py index 2848d41..adfe9f0 100644 --- a/olgram/commands/bots.py +++ b/olgram/commands/bots.py @@ -37,8 +37,12 @@ async def add_bot(message: types.Message, state: FSMContext): """ Команда /addbot (добавить бота) """ + user = await User.get_or_none(telegram_id=message.from_user.id) + max_bot_count = OlgramSettings.max_bots_per_user() + if user and await user.is_promo(): + max_bot_count = OlgramSettings.max_bots_per_user_promo() bot_count = await Bot.filter(owner__telegram_id=message.from_user.id).count() - if bot_count >= OlgramSettings.max_bots_per_user(): + if bot_count >= max_bot_count: await message.answer(_("У вас уже слишком много ботов. Удалите какой-нибудь свой бот из Olgram" "(/mybots -> (Выбрать бота) -> Удалить бот)")) return diff --git a/olgram/settings.py b/olgram/settings.py index 8bcdcd1..569102b 100644 --- a/olgram/settings.py +++ b/olgram/settings.py @@ -31,6 +31,14 @@ class OlgramSettings(AbstractSettings): """ return 10 + @classmethod + def max_bots_per_user_promo(cls) -> int: + """ + Максимальное количество ботов у одного пользователя с промо-доступом + :return: int + """ + return 25 + @classmethod def version(cls): return "0.3.3" diff --git a/server/custom.py b/server/custom.py index 0f98216..5a32a54 100644 --- a/server/custom.py +++ b/server/custom.py @@ -72,7 +72,7 @@ async def send_user_message(message: types.Message, super_chat_id: int, bot): user_info += f" | #{message.from_user.id}" # Добавлять информацию в конец текста - if isinstance(message.content_type, types.ContentType.TEXT) and len(message.text) + len(user_info) < 4093: + if message.content_type == types.ContentType.TEXT and len(message.text) + len(user_info) < 4093: # noqa:E721 new_message = await message.bot.send_message(super_chat_id, message.text + "\n\n" + user_info) else: # Не добавлять информацию в конец текста, информация отдельным сообщением new_message = await message.bot.send_message(super_chat_id, text=user_info)