This commit is contained in:
mihalin 2021-12-24 19:20:53 +03:00
parent 1a1d382243
commit 2786af259a
2 changed files with 32 additions and 0 deletions

26
olgram/commands/info.py Normal file
View File

@ -0,0 +1,26 @@
"""
Здесь метрики
"""
from aiogram import types
from aiogram.dispatcher import FSMContext
from olgram.models import models
from olgram.router import dp
from olgram.settings import OlgramSettings
@dp.message_handler(commands=["info"], state="*")
async def info(message: types.Message, state: FSMContext):
"""
Команда /info
"""
if message.from_user.id != OlgramSettings.supervisor_id():
return
bots_count = len(await models.Bot.all())
user_count = len(await models.User.all())
await message.answer(f"Количество ботов: {bots_count}"
f"Количество пользователей: {user_count}")

View File

@ -38,6 +38,12 @@ class OlgramSettings(AbstractSettings):
_id = cls._get_env("ADMIN_ID", True)
return int(_id) if _id else None
@classmethod
@lru_cache
def supervisor_id(cls):
_id = cls._get_env("SUPERVISOR_ID", True)
return int(_id) if _id else None
class ServerSettings(AbstractSettings):
@classmethod