mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🚑 语法适配到python3.8以上
This commit is contained in:
parent
03cfeb22d8
commit
8c65caf35f
@ -1,4 +1,4 @@
|
|||||||
from typing import Dict
|
from typing import Dict, Union
|
||||||
|
|
||||||
from tortoise import fields
|
from tortoise import fields
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class BagUser(Model):
|
|||||||
unique_together = ("user_id", "group_id")
|
unique_together = ("user_id", "group_id")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_total_gold(cls, user_id: str | int, group_id: str | int) -> str:
|
async def get_user_total_gold(cls, user_id: Union[int, str], group_id: Union[int, str]) -> str:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取金币概况
|
获取金币概况
|
||||||
@ -50,7 +50,7 @@ class BagUser(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_gold(cls, user_id: str | int, group_id: str | int) -> int:
|
async def get_gold(cls, user_id: Union[int, str], group_id: Union[int, str]) -> int:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取当前金币
|
获取当前金币
|
||||||
@ -63,7 +63,7 @@ class BagUser(Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_property(
|
async def get_property(
|
||||||
cls, user_id: str | int, group_id: str | int, only_active: bool = False
|
cls, user_id: Union[int, str], group_id: Union[int, str], only_active: bool = False
|
||||||
) -> Dict[str, int]:
|
) -> Dict[str, int]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
@ -87,7 +87,7 @@ class BagUser(Model):
|
|||||||
return user.property
|
return user.property
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def add_gold(cls, user_id: str | int, group_id: str | int, num: int):
|
async def add_gold(cls, user_id: Union[int, str], group_id: Union[int, str], num: int):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
增加金币
|
增加金币
|
||||||
@ -103,7 +103,7 @@ class BagUser(Model):
|
|||||||
await user.save(update_fields=["gold", "get_today_gold", "get_total_gold"])
|
await user.save(update_fields=["gold", "get_today_gold", "get_total_gold"])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def spend_gold(cls, user_id: str | int, group_id: str | int, num: int):
|
async def spend_gold(cls, user_id: Union[int, str], group_id: Union[int, str], num: int):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
花费金币
|
花费金币
|
||||||
@ -119,7 +119,7 @@ class BagUser(Model):
|
|||||||
await user.save(update_fields=["gold", "spend_total_gold", "spend_today_gold"])
|
await user.save(update_fields=["gold", "spend_total_gold", "spend_today_gold"])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def add_property(cls, user_id: str | int, group_id: str | int, name: str, num: int = 1):
|
async def add_property(cls, user_id: Union[int, str], group_id: Union[int, str], name: str, num: int = 1):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
增加道具
|
增加道具
|
||||||
@ -139,7 +139,7 @@ class BagUser(Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def delete_property(
|
async def delete_property(
|
||||||
cls, user_id: str | int, group_id: str | int, name: str, num: int = 1
|
cls, user_id: Union[int, str], group_id: Union[int, str], name: str, num: int = 1
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class BanUser(Model):
|
|||||||
table_description = ".ban/b了 封禁人员数据表"
|
table_description = ".ban/b了 封禁人员数据表"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def check_ban_level(cls, user_id: str | int, level: int) -> bool:
|
async def check_ban_level(cls, user_id: Union[int, str], level: int) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
检测ban掉目标的用户与unban用户的权限等级大小
|
检测ban掉目标的用户与unban用户的权限等级大小
|
||||||
@ -41,7 +41,7 @@ class BanUser(Model):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def check_ban_time(cls, user_id: str | int) -> Union[str, int]:
|
async def check_ban_time(cls, user_id: Union[int, str]) -> Union[str, int]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
检测用户被ban时长
|
检测用户被ban时长
|
||||||
@ -61,7 +61,7 @@ class BanUser(Model):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def is_ban(cls, user_id: str | int) -> bool:
|
async def is_ban(cls, user_id: Union[int, str]) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
判断用户是否被ban
|
判断用户是否被ban
|
||||||
@ -76,7 +76,7 @@ class BanUser(Model):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def is_super_ban(cls, user_id: str | int) -> bool:
|
async def is_super_ban(cls, user_id: Union[int, str]) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
判断用户是否被超级用户ban / b了
|
判断用户是否被超级用户ban / b了
|
||||||
@ -90,7 +90,7 @@ class BanUser(Model):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def ban(cls, user_id: str | int, ban_level: int, duration: int):
|
async def ban(cls, user_id: Union[int, str], ban_level: int, duration: int):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
ban掉目标用户
|
ban掉目标用户
|
||||||
@ -110,7 +110,7 @@ class BanUser(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def unban(cls, user_id: str | int) -> bool:
|
async def unban(cls, user_id: Union[int, str]) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
unban用户
|
unban用户
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class ChatHistory(Model):
|
|||||||
@classmethod
|
@classmethod
|
||||||
async def get_group_msg_rank(
|
async def get_group_msg_rank(
|
||||||
cls,
|
cls,
|
||||||
gid: str | int,
|
gid: Union[int, str],
|
||||||
limit: int = 10,
|
limit: int = 10,
|
||||||
order: str = "DESC",
|
order: str = "DESC",
|
||||||
date_scope: Optional[Tuple[datetime, datetime]] = None,
|
date_scope: Optional[Tuple[datetime, datetime]] = None,
|
||||||
@ -56,7 +56,7 @@ class ChatHistory(Model):
|
|||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_group_first_msg_datetime(cls, group_id: str | int) -> Optional[datetime]:
|
async def get_group_first_msg_datetime(cls, group_id: Union[int, str]) -> Optional[datetime]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取群第一条记录消息时间
|
获取群第一条记录消息时间
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from tortoise import fields
|
from tortoise import fields
|
||||||
|
from typing import Union
|
||||||
from configs.config import Config
|
from configs.config import Config
|
||||||
from services.db_context import Model
|
from services.db_context import Model
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class FriendUser(Model):
|
|||||||
table_description = "好友信息数据表"
|
table_description = "好友信息数据表"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_name(cls, user_id: str | int) -> str:
|
async def get_user_name(cls, user_id: Union[int, str]) -> str:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取好友用户名称
|
获取好友用户名称
|
||||||
@ -32,7 +32,7 @@ class FriendUser(Model):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_nickname(cls, user_id: str | int) -> str:
|
async def get_user_nickname(cls, user_id: Union[int, str]) -> str:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取用户昵称
|
获取用户昵称
|
||||||
@ -49,7 +49,7 @@ class FriendUser(Model):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def set_user_nickname(cls, user_id: str | int, nickname: str):
|
async def set_user_nickname(cls, user_id: Union[int, str], nickname: str):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
设置用户昵称
|
设置用户昵称
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from tortoise import fields
|
from tortoise import fields
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class GoodsInfo(Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def add_user_daily_purchase(
|
async def add_user_daily_purchase(
|
||||||
cls, goods: "GoodsInfo", user_id_: int, group_id_: int, num: int = 1
|
cls, goods: "GoodsInfo", user_id_: Union[int, str], group_id_: Union[int, str], num: int = 1
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
@ -168,7 +168,7 @@ class GoodsInfo(Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def check_user_daily_purchase(
|
async def check_user_daily_purchase(
|
||||||
cls, goods: "GoodsInfo", user_id_: int, group_id_: int, num: int = 1
|
cls, goods: "GoodsInfo", user_id_: Union[int, str], group_id_: Union[int, str], num: int = 1
|
||||||
) -> Tuple[bool, int]:
|
) -> Tuple[bool, int]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Optional, Set
|
from typing import List, Optional, Set, Union
|
||||||
|
|
||||||
from tortoise import fields
|
from tortoise import fields
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class GroupInfoUser(Model):
|
|||||||
unique_together = ("user_id", "group_id")
|
unique_together = ("user_id", "group_id")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_group_member_id_list(cls, group_id: str | int) -> Set[int]:
|
async def get_group_member_id_list(cls, group_id: Union[int, str]) -> Set[int]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取该群所有用户id
|
获取该群所有用户id
|
||||||
@ -43,7 +43,7 @@ class GroupInfoUser(Model):
|
|||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def set_user_nickname(cls, user_id: str | int, group_id: str | int, nickname: str):
|
async def set_user_nickname(cls, user_id: Union[int, str], group_id: Union[int, str], nickname: str):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
设置群员在该群内的昵称
|
设置群员在该群内的昵称
|
||||||
@ -59,7 +59,7 @@ class GroupInfoUser(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_all_group(cls, user_id: str | int) -> List[int]:
|
async def get_user_all_group(cls, user_id: Union[int, str]) -> List[int]:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取该用户所在的所有群聊
|
获取该用户所在的所有群聊
|
||||||
@ -71,7 +71,7 @@ class GroupInfoUser(Model):
|
|||||||
) # type: ignore
|
) # type: ignore
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_nickname(cls, user_id: str | int, group_id: str | int) -> str:
|
async def get_user_nickname(cls, user_id: Union[int, str], group_id: Union[int, str]) -> str:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取用户在该群的昵称
|
获取用户在该群的昵称
|
||||||
@ -90,7 +90,7 @@ class GroupInfoUser(Model):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_group_member_uid(cls, user_id: str | int, group_id: str | int) -> Optional[int]:
|
async def get_group_member_uid(cls, user_id: Union[int, str], group_id: Union[int, str]) -> Optional[int]:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"GroupInfoUser 尝试获取 用户[<u><e>{user_id}</e></u>] 群聊[<u><e>{group_id}</e></u>] UID"
|
f"GroupInfoUser 尝试获取 用户[<u><e>{user_id}</e></u>] 群聊[<u><e>{group_id}</e></u>] UID"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from tortoise import fields
|
from tortoise import fields
|
||||||
|
|
||||||
from services.db_context import Model
|
from services.db_context import Model
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
class LevelUser(Model):
|
class LevelUser(Model):
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class LevelUser(Model):
|
|||||||
unique_together = ("user_id", "group_id")
|
unique_together = ("user_id", "group_id")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get_user_level(cls, user_id: str | int, group_id: str | int) -> int:
|
async def get_user_level(cls, user_id: Union[int, str], group_id: Union[int, str]) -> int:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
获取用户在群内的等级
|
获取用户在群内的等级
|
||||||
@ -36,7 +36,7 @@ class LevelUser(Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def set_level(
|
async def set_level(
|
||||||
cls, user_id: str | int, group_id: str | int, level: int, group_flag: int = 0
|
cls, user_id: Union[int, str], group_id: Union[int, str], level: int, group_flag: int = 0
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
@ -54,7 +54,7 @@ class LevelUser(Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def delete_level(cls, user_id: str | int, group_id: str | int) -> bool:
|
async def delete_level(cls, user_id: Union[int, str], group_id: Union[int, str]) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
删除用户权限
|
删除用户权限
|
||||||
@ -68,7 +68,7 @@ class LevelUser(Model):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def check_level(cls, user_id: str | int, group_id: str | int, level: int) -> bool:
|
async def check_level(cls, user_id: Union[int, str], group_id: Union[int, str], level: int) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
检查用户权限等级是否大于 level
|
检查用户权限等级是否大于 level
|
||||||
@ -87,7 +87,7 @@ class LevelUser(Model):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def is_group_flag(cls, user_id: str | int, group_id: str | int) -> bool:
|
async def is_group_flag(cls, user_id: Union[int, str], group_id: Union[int, str]) -> bool:
|
||||||
"""
|
"""
|
||||||
说明:
|
说明:
|
||||||
检测是否会被自动更新刷新权限
|
检测是否会被自动更新刷新权限
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user