mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 添加 override 标记
This commit is contained in:
@@ -8,6 +8,7 @@ from nonebot_plugin_orm import Model
|
|||||||
from pydantic import BaseModel, ValidationError
|
from pydantic import BaseModel, ValidationError
|
||||||
from sqlalchemy import JSON, DateTime, Dialect, PickleType, String, TypeDecorator
|
from sqlalchemy import JSON, DateTime, Dialect, PickleType, String, TypeDecorator
|
||||||
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
|
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
from ..game_data_processor.schemas import BaseProcessedData, BaseUser
|
from ..game_data_processor.schemas import BaseProcessedData, BaseUser
|
||||||
from ..utils.typing import CommandType, GameType
|
from ..utils.typing import CommandType, GameType
|
||||||
@@ -16,17 +17,20 @@ from ..utils.typing import CommandType, GameType
|
|||||||
class PydanticType(TypeDecorator):
|
class PydanticType(TypeDecorator):
|
||||||
impl = JSON
|
impl = JSON
|
||||||
|
|
||||||
def __init__(self, get_model: Callable[[], Sequence[type[BaseModel]]], *args: Any, **kwargs: Any): # noqa: ANN401
|
@override
|
||||||
|
def __init__(self, get_model: Callable[[], Sequence[type[BaseModel]]], *args: Any, **kwargs: Any):
|
||||||
self.get_model = get_model
|
self.get_model = get_model
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def process_bind_param(self, value: Any | None, dialect: Dialect) -> str: # noqa: ANN401
|
@override
|
||||||
|
def process_bind_param(self, value: Any | None, dialect: Dialect) -> str:
|
||||||
# 将 Pydantic 模型实例转换为 JSON
|
# 将 Pydantic 模型实例转换为 JSON
|
||||||
if isinstance(value, tuple(self.get_model())):
|
if isinstance(value, tuple(self.get_model())):
|
||||||
return value.json() # type: ignore[union-attr]
|
return value.json() # type: ignore[union-attr]
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
def process_result_value(self, value: Any | None, dialect: Dialect) -> BaseModel: # noqa: ANN401
|
@override
|
||||||
|
def process_result_value(self, value: Any | None, dialect: Dialect) -> BaseModel:
|
||||||
# 将 JSON 转换回 Pydantic 模型实例
|
# 将 JSON 转换回 Pydantic 模型实例
|
||||||
if isinstance(value, str | bytes):
|
if isinstance(value, str | bytes):
|
||||||
for i in self.get_model():
|
for i in self.get_model():
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from nonebot_plugin_localstore import get_data_file # type: ignore[import-untyp
|
|||||||
from nonebot_plugin_orm import get_session
|
from nonebot_plugin_orm import get_session
|
||||||
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
|
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
from typing_extensions import override
|
||||||
from zstandard import ZstdCompressor
|
from zstandard import ZstdCompressor
|
||||||
|
|
||||||
from ...db import BindStatus, create_or_update_bind
|
from ...db import BindStatus, create_or_update_bind
|
||||||
@@ -63,15 +64,18 @@ class Processor(ProcessorMeta):
|
|||||||
raw_response: RawResponse
|
raw_response: RawResponse
|
||||||
processed_data: ProcessedData
|
processed_data: ProcessedData
|
||||||
|
|
||||||
|
@override
|
||||||
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
||||||
super().__init__(event_id, user, command_args)
|
super().__init__(event_id, user, command_args)
|
||||||
self.raw_response = RawResponse()
|
self.raw_response = RawResponse()
|
||||||
self.processed_data = ProcessedData()
|
self.processed_data = ProcessedData()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@override
|
||||||
def game_platform(self) -> Literal['IO']:
|
def game_platform(self) -> Literal['IO']:
|
||||||
return GAME_TYPE
|
return GAME_TYPE
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_bind(self, platform: str, account: str, bot_info: NBUserInfo) -> UniMessage:
|
async def handle_bind(self, platform: str, account: str, bot_info: NBUserInfo) -> UniMessage:
|
||||||
"""处理绑定消息"""
|
"""处理绑定消息"""
|
||||||
self.command_type = 'bind'
|
self.command_type = 'bind'
|
||||||
@@ -110,6 +114,7 @@ class Processor(ProcessorMeta):
|
|||||||
)
|
)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_query(self) -> str:
|
async def handle_query(self) -> str:
|
||||||
"""处理查询消息"""
|
"""处理查询消息"""
|
||||||
self.command_type = 'query'
|
self.command_type = 'query'
|
||||||
@@ -149,6 +154,7 @@ class Processor(ProcessorMeta):
|
|||||||
self.processed_data.user_records = user_records
|
self.processed_data.user_records = user_records
|
||||||
return self.processed_data.user_records
|
return self.processed_data.user_records
|
||||||
|
|
||||||
|
@override
|
||||||
async def generate_message(self) -> str:
|
async def generate_message(self) -> str:
|
||||||
"""生成消息"""
|
"""生成消息"""
|
||||||
user_info = await self.get_user_info()
|
user_info = await self.get_user_info()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from nonebot_plugin_alconna.uniseg import UniMessage
|
|||||||
from nonebot_plugin_orm import get_session
|
from nonebot_plugin_orm import get_session
|
||||||
from nonebot_plugin_userinfo import UserInfo # type: ignore[import-untyped]
|
from nonebot_plugin_userinfo import UserInfo # type: ignore[import-untyped]
|
||||||
from pandas import read_html
|
from pandas import read_html
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
from ...db import BindStatus, create_or_update_bind
|
from ...db import BindStatus, create_or_update_bind
|
||||||
from ...utils.avatar import get_avatar
|
from ...utils.avatar import get_avatar
|
||||||
@@ -30,6 +31,7 @@ class User(BaseUser):
|
|||||||
name: str
|
name: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@override
|
||||||
def unique_identifier(self) -> str:
|
def unique_identifier(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@@ -57,15 +59,18 @@ class Processor(ProcessorMeta):
|
|||||||
raw_response: RawResponse
|
raw_response: RawResponse
|
||||||
processed_data: ProcessedData
|
processed_data: ProcessedData
|
||||||
|
|
||||||
|
@override
|
||||||
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
||||||
super().__init__(event_id, user, command_args)
|
super().__init__(event_id, user, command_args)
|
||||||
self.raw_response = RawResponse()
|
self.raw_response = RawResponse()
|
||||||
self.processed_data = ProcessedData()
|
self.processed_data = ProcessedData()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@override
|
||||||
def game_platform(self) -> Literal['TOP']:
|
def game_platform(self) -> Literal['TOP']:
|
||||||
return GAME_TYPE
|
return GAME_TYPE
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_bind(self, platform: str, account: str, bot_info: UserInfo, user_info: UserInfo) -> UniMessage:
|
async def handle_bind(self, platform: str, account: str, bot_info: UserInfo, user_info: UserInfo) -> UniMessage:
|
||||||
"""处理绑定消息"""
|
"""处理绑定消息"""
|
||||||
self.command_type = 'bind'
|
self.command_type = 'bind'
|
||||||
@@ -99,6 +104,7 @@ class Processor(ProcessorMeta):
|
|||||||
)
|
)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_query(self) -> str:
|
async def handle_query(self) -> str:
|
||||||
"""处理查询消息"""
|
"""处理查询消息"""
|
||||||
self.command_type = 'query'
|
self.command_type = 'query'
|
||||||
@@ -141,6 +147,7 @@ class Processor(ProcessorMeta):
|
|||||||
total = Data(lpm=dataframe['lpm'].mean(), apm=dataframe['apm'].mean()) if len(dataframe) != 0 else None
|
total = Data(lpm=dataframe['lpm'].mean(), apm=dataframe['apm'].mean()) if len(dataframe) != 0 else None
|
||||||
return GameData(day=day, total=total)
|
return GameData(day=day, total=total)
|
||||||
|
|
||||||
|
@override
|
||||||
async def generate_message(self) -> str:
|
async def generate_message(self) -> str:
|
||||||
"""生成消息"""
|
"""生成消息"""
|
||||||
game_data = await self.get_game_data()
|
game_data = await self.get_game_data()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from nonebot.compat import type_validate_json
|
|||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
||||||
from nonebot_plugin_orm import get_session
|
from nonebot_plugin_orm import get_session
|
||||||
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
|
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
from ...db import BindStatus, create_or_update_bind
|
from ...db import BindStatus, create_or_update_bind
|
||||||
from ...utils.avatar import get_avatar
|
from ...utils.avatar import get_avatar
|
||||||
@@ -32,6 +33,7 @@ class User(BaseUser):
|
|||||||
name: str | None = None
|
name: str | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@override
|
||||||
def unique_identifier(self) -> str:
|
def unique_identifier(self) -> str:
|
||||||
if self.teaid is None:
|
if self.teaid is None:
|
||||||
raise ValueError('不完整的User!')
|
raise ValueError('不完整的User!')
|
||||||
@@ -70,15 +72,18 @@ class Processor(ProcessorMeta):
|
|||||||
raw_response: RawResponse
|
raw_response: RawResponse
|
||||||
processed_data: ProcessedData
|
processed_data: ProcessedData
|
||||||
|
|
||||||
|
@override
|
||||||
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
|
||||||
super().__init__(event_id, user, command_args)
|
super().__init__(event_id, user, command_args)
|
||||||
self.raw_response = RawResponse(user_profile={})
|
self.raw_response = RawResponse(user_profile={})
|
||||||
self.processed_data = ProcessedData(user_profile={})
|
self.processed_data = ProcessedData(user_profile={})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@override
|
||||||
def game_platform(self) -> Literal['TOS']:
|
def game_platform(self) -> Literal['TOS']:
|
||||||
return GAME_TYPE
|
return GAME_TYPE
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_bind(self, platform: str, account: str, bot_info: NBUserInfo) -> UniMessage:
|
async def handle_bind(self, platform: str, account: str, bot_info: NBUserInfo) -> UniMessage:
|
||||||
"""处理绑定消息"""
|
"""处理绑定消息"""
|
||||||
self.command_type = 'bind'
|
self.command_type = 'bind'
|
||||||
@@ -113,6 +118,7 @@ class Processor(ProcessorMeta):
|
|||||||
)
|
)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@override
|
||||||
async def handle_query(self) -> str:
|
async def handle_query(self) -> str:
|
||||||
"""处理查询消息"""
|
"""处理查询消息"""
|
||||||
self.command_type = 'query'
|
self.command_type = 'query'
|
||||||
@@ -229,6 +235,7 @@ class Processor(ProcessorMeta):
|
|||||||
vs=round((adpm / 60 * 100), 2),
|
vs=round((adpm / 60 * 100), 2),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@override
|
||||||
async def generate_message(self) -> str:
|
async def generate_message(self) -> str:
|
||||||
"""生成消息"""
|
"""生成消息"""
|
||||||
user_info = (await self.get_user_info()).data
|
user_info = (await self.get_user_info()).data
|
||||||
|
|||||||
Reference in New Issue
Block a user