mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
max bot count for promo
This commit is contained in:
parent
c58a4b90d5
commit
03437146f1
@ -37,8 +37,12 @@ async def add_bot(message: types.Message, state: FSMContext):
|
|||||||
"""
|
"""
|
||||||
Команда /addbot (добавить бота)
|
Команда /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()
|
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"
|
await message.answer(_("У вас уже слишком много ботов. Удалите какой-нибудь свой бот из Olgram"
|
||||||
"(/mybots -> (Выбрать бота) -> Удалить бот)"))
|
"(/mybots -> (Выбрать бота) -> Удалить бот)"))
|
||||||
return
|
return
|
||||||
|
@ -31,6 +31,14 @@ class OlgramSettings(AbstractSettings):
|
|||||||
"""
|
"""
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def max_bots_per_user_promo(cls) -> int:
|
||||||
|
"""
|
||||||
|
Максимальное количество ботов у одного пользователя с промо-доступом
|
||||||
|
:return: int
|
||||||
|
"""
|
||||||
|
return 25
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def version(cls):
|
def version(cls):
|
||||||
return "0.3.3"
|
return "0.3.3"
|
||||||
|
@ -72,7 +72,7 @@ async def send_user_message(message: types.Message, super_chat_id: int, bot):
|
|||||||
user_info += f" | #{message.from_user.id}"
|
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)
|
new_message = await message.bot.send_message(super_chat_id, message.text + "\n\n" + user_info)
|
||||||
else: # Не добавлять информацию в конец текста, информация отдельным сообщением
|
else: # Не добавлять информацию в конец текста, информация отдельным сообщением
|
||||||
new_message = await message.bot.send_message(super_chat_id, text=user_info)
|
new_message = await message.bot.send_message(super_chat_id, text=user_info)
|
||||||
|
Loading…
Reference in New Issue
Block a user