⚡️ 代码优化

This commit is contained in:
HibiKier
2024-08-08 21:43:40 +08:00
parent 8470777f6c
commit f02c276310
8 changed files with 145 additions and 22 deletions
+16
View File
@@ -1,4 +1,5 @@
from tortoise import fields
from typing_extensions import Self
from zhenxun.services.db_context import Model
@@ -39,6 +40,21 @@ class GroupConsole(Model):
table_description = "群组信息表"
unique_together = ("group_id", "channel_id")
@classmethod
async def get_group(cls, group_id: str, channel_id: str | None = None) -> Self:
"""获取群组
参数:
group_id: 群组id
channel_id: 频道id.
返回:
Self: GroupConsole
"""
if channel_id:
return await cls.get(group_id=group_id, channel_id=channel_id)
return await cls.get(group_id=group_id, channel_id__isnull=True)
@classmethod
async def is_super_group(cls, group_id: str, channel_id: str | None = None) -> bool:
"""是否超级用户指定群