Compare commits

..

3 Commits

Author SHA1 Message Date
67cfb07246 🔖 1.0.0.a11 2024-01-03 09:37:36 +08:00
12145a614f ⬇️ 错误的使用了Python3.11的新特性 2024-01-03 09:37:10 +08:00
0b07882a16 🐛 修复事件没有正确结束的bug 2024-01-03 09:27:26 +08:00
9 changed files with 31 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from datetime import UTC, datetime from datetime import datetime, timezone
from typing import Any from typing import Any
from nonebot.matcher import Matcher from nonebot.matcher import Matcher
@@ -12,6 +12,8 @@ from .schemas import BaseProcessedData as ProcessedData
from .schemas import BaseRawResponse as RawResponse from .schemas import BaseRawResponse as RawResponse
from .schemas import BaseUser as User from .schemas import BaseUser as User
UTC = timezone.utc
class Processor(ABC): class Processor(ABC):
event_id: int event_id: int

View File

@@ -1,4 +1,4 @@
from datetime import UTC, datetime, timedelta from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from arclet.alconna import Alconna, AllParam, Arg, ArgFlag, Args, CommandMeta, Option from arclet.alconna import Alconna, AllParam, Arg, ArgFlag, Args, CommandMeta, Option
@@ -20,6 +20,8 @@ from .model import IORank
from .processor import Processor, User, identify_user_info from .processor import Processor, User, identify_user_info
from .typing import Rank from .typing import Rank
UTC = timezone.utc
alc = on_alconna( alc = on_alconna(
Alconna( Alconna(
'io', 'io',
@@ -91,7 +93,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) await matcher.finish(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id()))
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -115,7 +117,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(message + await proc.handle_query()) await matcher.finish(message + await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -129,7 +131,7 @@ async def _(event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_query()) await matcher.finish(await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e

View File

@@ -1,4 +1,4 @@
from datetime import UTC, datetime from datetime import datetime, timezone
from aiocache import Cache as ACache # type: ignore[import-untyped] from aiocache import Cache as ACache # type: ignore[import-untyped]
from nonebot.log import logger from nonebot.log import logger
@@ -7,6 +7,8 @@ from pydantic import parse_raw_as
from ...utils.request import Request from ...utils.request import Request
from .schemas.base import FailedModel, SuccessModel from .schemas.base import FailedModel, SuccessModel
UTC = timezone.utc
class Cache: class Cache:
cache = ACache(ACache.MEMORY) cache = ACache(ACache.MEMORY)

View File

@@ -1,4 +1,4 @@
from datetime import UTC, datetime from datetime import datetime, timezone
from nonebot_plugin_orm import Model from nonebot_plugin_orm import Model
from sqlalchemy import JSON, DateTime, String from sqlalchemy import JSON, DateTime, String
@@ -6,6 +6,8 @@ from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
from .typing import Rank from .typing import Rank
UTC = timezone.utc
class IORank(MappedAsDataclass, Model): class IORank(MappedAsDataclass, Model):
id: Mapped[int] = mapped_column(init=False, primary_key=True) id: Mapped[int] = mapped_column(init=False, primary_key=True)

View File

@@ -1,6 +1,6 @@
from collections import defaultdict from collections import defaultdict
from collections.abc import Callable from collections.abc import Callable
from datetime import UTC, datetime, timedelta from datetime import datetime, timedelta, timezone
from math import floor from math import floor
from re import match from re import match
from statistics import mean from statistics import mean
@@ -33,6 +33,8 @@ from .schemas.user_records import SoloRecord, UserRecords
from .schemas.user_records import SuccessModel as RecordsSuccess from .schemas.user_records import SuccessModel as RecordsSuccess
from .typing import Rank from .typing import Rank
UTC = timezone.utc
driver = get_driver() driver = get_driver()

View File

@@ -74,7 +74,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) await matcher.finish(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id()))
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -98,7 +98,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(message + await proc.handle_query()) await matcher.finish(message + await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -112,7 +112,7 @@ async def _(event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_query()) await matcher.finish(await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e

View File

@@ -94,6 +94,7 @@ try:
command_args=[], command_args=[],
) )
await finish_special_query(matcher, proc) await finish_special_query(matcher, proc)
except ImportError: except ImportError:
pass pass
@@ -108,6 +109,7 @@ try:
command_args=[], command_args=[],
) )
await finish_special_query(matcher, proc) await finish_special_query(matcher, proc)
except ImportError: except ImportError:
pass pass
@@ -122,6 +124,7 @@ try:
command_args=[], command_args=[],
) )
await finish_special_query(matcher, proc) await finish_special_query(matcher, proc)
except ImportError: except ImportError:
pass pass
@@ -134,7 +137,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id())) await matcher.finish(await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id()))
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -158,7 +161,7 @@ async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(message + await proc.handle_query()) await matcher.finish(message + await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e
@@ -172,7 +175,7 @@ async def _(event: Event, matcher: Matcher, account: User):
command_args=[], command_args=[],
) )
try: try:
await matcher.send(await proc.handle_query()) await matcher.finish(await proc.handle_query())
except NeedCatchError as e: except NeedCatchError as e:
await matcher.send(str(e)) await matcher.send(str(e))
raise HandleNotFinishedError from e raise HandleNotFinishedError from e

View File

@@ -1,4 +1,4 @@
from datetime import UTC, datetime from datetime import datetime, timezone
from typing import ClassVar from typing import ClassVar
from nonebot import get_driver, get_plugin from nonebot import get_driver, get_plugin
@@ -9,6 +9,8 @@ from nonebot_plugin_orm import get_session
from ..db.models import HistoricalData from ..db.models import HistoricalData
UTC = timezone.utc
driver = get_driver() driver = get_driver()

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = 'nonebot-plugin-tetris-stats' name = 'nonebot-plugin-tetris-stats'
version = '1.0.0.a10' version = '1.0.0.a11'
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件' description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
authors = ['scdhh <wallfjjd@gmail.com>'] authors = ['scdhh <wallfjjd@gmail.com>']
readme = 'README.md' readme = 'README.md'