mirror of
https://github.com/civsocit/olgram.git
synced 2023-07-22 01:29:12 +03:00
info
This commit is contained in:
parent
1a1d382243
commit
2786af259a
26
olgram/commands/info.py
Normal file
26
olgram/commands/info.py
Normal 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}")
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user