mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 435850819c | |||
| 6f439ad357 | |||
| b74cc1f4a0 | |||
| 1a1c2675d1 | |||
| 1f02c107f5 | |||
| 89c319a500 | |||
| 56f9a69c4d | |||
| 50431fe7cb | |||
| 71ad53a1f9 | |||
| 820393f216 | |||
| 27994cea6b | |||
|
|
eb753cb059 | ||
|
|
256d13d1df | ||
|
|
d8d56b44db | ||
|
|
57a57f0259 | ||
|
|
4f7f4a3e33 | ||
|
|
367a9a8297 | ||
|
|
009dd90609 | ||
| 8e6e0dc274 | |||
|
|
df7efc6707 | ||
|
|
d783ecd3eb | ||
|
|
13f3e34f79 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,3 +20,5 @@ bot.py
|
|||||||
TODO
|
TODO
|
||||||
*.fish
|
*.fish
|
||||||
extracted_skin_mino_*
|
extracted_skin_mino_*
|
||||||
|
sample_*
|
||||||
|
TODO*
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -87,3 +87,13 @@ pip install nonebot-plugin-tetris-stats
|
|||||||
## 📝 开源
|
## 📝 开源
|
||||||
|
|
||||||
本项目使用 [AGPL-3.0](https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats/blob/main/LICENSE) 许可证开源
|
本项目使用 [AGPL-3.0](https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats/blob/main/LICENSE) 许可证开源
|
||||||
|
|
||||||
|
## 🤓☝ 给个 star 吧
|
||||||
|
|
||||||
|
<a href="https://star-history.com/#A-Minos/nonebot-plugin-tetris-stats&Date">
|
||||||
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=A-Minos/nonebot-plugin-tetris-stats&type=Date&theme=dark" />
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=A-Minos/nonebot-plugin-tetris-stats&type=Date" />
|
||||||
|
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=A-Minos/nonebot-plugin-tetris-stats&type=Date" />
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
from nonebot import require
|
from nonebot import require
|
||||||
from nonebot.plugin import PluginMetadata
|
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
||||||
|
|
||||||
require('nonebot_plugin_alconna')
|
require_plugins = {
|
||||||
require('nonebot_plugin_apscheduler')
|
'nonebot_plugin_alconna',
|
||||||
require('nonebot_plugin_localstore')
|
'nonebot_plugin_apscheduler',
|
||||||
require('nonebot_plugin_orm')
|
'nonebot_plugin_localstore',
|
||||||
require('nonebot_plugin_session_orm')
|
'nonebot_plugin_orm',
|
||||||
require('nonebot_plugin_session')
|
'nonebot_plugin_session_orm',
|
||||||
require('nonebot_plugin_user')
|
'nonebot_plugin_session',
|
||||||
require('nonebot_plugin_userinfo')
|
'nonebot_plugin_user',
|
||||||
|
'nonebot_plugin_userinfo',
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in require_plugins:
|
||||||
|
require(i)
|
||||||
|
|
||||||
from nonebot_plugin_alconna import namespace # noqa: E402
|
from nonebot_plugin_alconna import namespace # noqa: E402
|
||||||
|
|
||||||
@@ -16,6 +21,7 @@ with namespace('tetris_stats') as ns:
|
|||||||
ns.enable_message_cache = False
|
ns.enable_message_cache = False
|
||||||
|
|
||||||
from .config import migrations # noqa: E402
|
from .config import migrations # noqa: E402
|
||||||
|
from .config.config import Config # noqa: E402
|
||||||
|
|
||||||
__plugin_meta__ = PluginMetadata(
|
__plugin_meta__ = PluginMetadata(
|
||||||
name='Tetris Stats',
|
name='Tetris Stats',
|
||||||
@@ -23,6 +29,8 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
usage='发送 tstats --help 查询使用方法',
|
usage='发送 tstats --help 查询使用方法',
|
||||||
type='application',
|
type='application',
|
||||||
homepage='https://github.com/A-minos/nonebot-plugin-tetris-stats',
|
homepage='https://github.com/A-minos/nonebot-plugin-tetris-stats',
|
||||||
|
config=Config,
|
||||||
|
supported_adapters=inherit_supported_adapters(*require_plugins),
|
||||||
extra={
|
extra={
|
||||||
'orm_version_location': migrations,
|
'orm_version_location': migrations,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
"""TETR.IO new season
|
||||||
|
|
||||||
|
迁移 ID: f5b4a6d1325b
|
||||||
|
父迁移: a1195e989cc6
|
||||||
|
创建时间: 2024-08-01 20:44:48.644912
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
|
revision: str = 'f5b4a6d1325b'
|
||||||
|
down_revision: str | Sequence[str] | None = 'a1195e989cc6'
|
||||||
|
branch_labels: str | Sequence[str] | None = None
|
||||||
|
depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(name: str = '') -> None:
|
||||||
|
if name:
|
||||||
|
return
|
||||||
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_iorank_file_hash')
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_iorank_rank')
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_iorank_update_time')
|
||||||
|
|
||||||
|
op.drop_table('nonebot_plugin_tetris_stats_iorank')
|
||||||
|
|
||||||
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetriohistoricaldata', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_api_type')
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_update_time')
|
||||||
|
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_user_unique_identifier')
|
||||||
|
|
||||||
|
op.drop_table('nonebot_plugin_tetris_stats_tetriohistoricaldata')
|
||||||
|
|
||||||
|
op.create_table(
|
||||||
|
'nonebot_plugin_tetris_stats_tetriohistoricaldata',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('user_unique_identifier', sa.String(length=24), nullable=False),
|
||||||
|
sa.Column('api_type', sa.String(length=16), nullable=False),
|
||||||
|
sa.Column('data', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('update_time', sa.DateTime(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_tetriohistoricaldata')),
|
||||||
|
info={'bind_key': 'nonebot_plugin_tetris_stats'},
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_tetriohistoricaldata', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(
|
||||||
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_api_type'), ['api_type'], unique=False
|
||||||
|
)
|
||||||
|
batch_op.create_index(
|
||||||
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_update_time'), ['update_time'], unique=False
|
||||||
|
)
|
||||||
|
batch_op.create_index(
|
||||||
|
batch_op.f('ix_nonebot_plugin_tetris_stats_tetriohistoricaldata_user_unique_identifier'),
|
||||||
|
['user_unique_identifier'],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(name: str = '') -> None:
|
||||||
|
if name:
|
||||||
|
return
|
||||||
|
op.create_table(
|
||||||
|
'nonebot_plugin_tetris_stats_iorank',
|
||||||
|
sa.Column('id', sa.INTEGER(), nullable=False),
|
||||||
|
sa.Column('rank', sa.VARCHAR(length=2), nullable=False),
|
||||||
|
sa.Column('tr_line', sa.FLOAT(), nullable=False),
|
||||||
|
sa.Column('player_count', sa.INTEGER(), nullable=False),
|
||||||
|
sa.Column('low_pps', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('low_apm', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('low_vs', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('avg_pps', sa.FLOAT(), nullable=False),
|
||||||
|
sa.Column('avg_apm', sa.FLOAT(), nullable=False),
|
||||||
|
sa.Column('avg_vs', sa.FLOAT(), nullable=False),
|
||||||
|
sa.Column('high_pps', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('high_apm', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('high_vs', sa.JSON(), nullable=False),
|
||||||
|
sa.Column('update_time', sa.DATETIME(), nullable=False),
|
||||||
|
sa.Column('file_hash', sa.VARCHAR(length=128), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id', name='pk_nonebot_plugin_tetris_stats_iorank'),
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
|
||||||
|
batch_op.create_index('ix_nonebot_plugin_tetris_stats_iorank_update_time', ['update_time'], unique=False)
|
||||||
|
batch_op.create_index('ix_nonebot_plugin_tetris_stats_iorank_rank', ['rank'], unique=False)
|
||||||
|
batch_op.create_index('ix_nonebot_plugin_tetris_stats_iorank_file_hash', ['file_hash'], unique=False)
|
||||||
@@ -3,9 +3,12 @@ from nonebot_plugin_alconna import At
|
|||||||
|
|
||||||
from ...utils.exception import MessageFormatError
|
from ...utils.exception import MessageFormatError
|
||||||
from ...utils.typing import Me
|
from ...utils.typing import Me
|
||||||
from .. import add_block_handlers, alc, command
|
|
||||||
|
# from .. import add_block_handlers, alc, command
|
||||||
|
from .. import alc, command
|
||||||
from .api import Player
|
from .api import Player
|
||||||
from .api.typing import ValidRank
|
|
||||||
|
# from .api.typing import ValidRank
|
||||||
from .constant import USER_ID, USER_NAME
|
from .constant import USER_ID, USER_NAME
|
||||||
from .typing import Template
|
from .typing import Template
|
||||||
|
|
||||||
@@ -33,30 +36,30 @@ command.add(
|
|||||||
),
|
),
|
||||||
help_text='绑定 TETR.IO 账号',
|
help_text='绑定 TETR.IO 账号',
|
||||||
),
|
),
|
||||||
Subcommand(
|
# Subcommand(
|
||||||
'query',
|
# 'query',
|
||||||
Args(
|
# Args(
|
||||||
Arg(
|
# Arg(
|
||||||
'target',
|
# 'target',
|
||||||
At | Me,
|
# At | Me,
|
||||||
notice='@想要查询的人 / 自己',
|
# notice='@想要查询的人 / 自己',
|
||||||
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
# flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||||
),
|
# ),
|
||||||
Arg(
|
# Arg(
|
||||||
'account',
|
# 'account',
|
||||||
get_player,
|
# get_player,
|
||||||
notice='TETR.IO 用户名 / ID',
|
# notice='TETR.IO 用户名 / ID',
|
||||||
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
# flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||||
),
|
# ),
|
||||||
),
|
# ),
|
||||||
Option(
|
# Option(
|
||||||
'--template',
|
# '--template',
|
||||||
Arg('template', Template),
|
# Arg('template', Template),
|
||||||
alias=['-T'],
|
# alias=['-T'],
|
||||||
help_text='要使用的查询模板',
|
# help_text='要使用的查询模板',
|
||||||
),
|
# ),
|
||||||
help_text='查询 TETR.IO 游戏信息',
|
# help_text='查询 TETR.IO 游戏信息',
|
||||||
),
|
# ),
|
||||||
Subcommand(
|
Subcommand(
|
||||||
'record',
|
'record',
|
||||||
Option(
|
Option(
|
||||||
@@ -82,27 +85,33 @@ command.add(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Subcommand(
|
# Subcommand(
|
||||||
'list',
|
# 'list',
|
||||||
Option('--max-tr', Arg('max_tr', float), help_text='TR的上限'),
|
# Option('--max-tr', Arg('max_tr', float), help_text='TR的上限'),
|
||||||
Option('--min-tr', Arg('min_tr', float), help_text='TR的下限'),
|
# Option('--min-tr', Arg('min_tr', float), help_text='TR的下限'),
|
||||||
Option('--limit', Arg('limit', int), help_text='查询数量'),
|
# Option('--limit', Arg('limit', int), help_text='查询数量'),
|
||||||
Option('--country', Arg('country', str), help_text='国家代码'),
|
# Option('--country', Arg('country', str), help_text='国家代码'),
|
||||||
help_text='查询 TETR.IO 段位排行榜',
|
# help_text='查询 TETR.IO 段位排行榜',
|
||||||
),
|
# ),
|
||||||
Subcommand(
|
# Subcommand(
|
||||||
'rank',
|
# 'rank',
|
||||||
Option(
|
# Subcommand(
|
||||||
'--all',
|
# '--all',
|
||||||
dest='all',
|
# Option(
|
||||||
),
|
# '--template',
|
||||||
Option(
|
# Arg('template', Template),
|
||||||
'--detail',
|
# alias=['-T'],
|
||||||
Arg('rank', ValidRank),
|
# help_text='要使用的查询模板',
|
||||||
alias=['-D'],
|
# ),
|
||||||
),
|
# dest='all',
|
||||||
help_text='查询 TETR.IO 段位信息',
|
# ),
|
||||||
),
|
# Option(
|
||||||
|
# '--detail',
|
||||||
|
# Arg('rank', ValidRank),
|
||||||
|
# alias=['-D'],
|
||||||
|
# ),
|
||||||
|
# help_text='查询 TETR.IO 段位信息',
|
||||||
|
# ),
|
||||||
Subcommand(
|
Subcommand(
|
||||||
'config',
|
'config',
|
||||||
Option(
|
Option(
|
||||||
@@ -111,18 +120,19 @@ command.add(
|
|||||||
alias=['-DT', 'DefaultTemplate'],
|
alias=['-DT', 'DefaultTemplate'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
alias=['TETRIO', 'tetr.io', 'tetrio', 'io'],
|
||||||
dest='TETRIO',
|
dest='TETRIO',
|
||||||
help_text='TETR.IO 游戏相关指令',
|
help_text='TETR.IO 游戏相关指令',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def rank_wrapper(slot: int | str, content: str | None):
|
# def rank_wrapper(slot: int | str, content: str | None):
|
||||||
if slot == 'rank' and not content:
|
# if slot == 'rank' and not content:
|
||||||
return '--all'
|
# return '--all'
|
||||||
if content is not None:
|
# if content is not None:
|
||||||
return f'--detail {content.lower()}'
|
# return f'--detail {content.lower()}'
|
||||||
return content
|
# return content
|
||||||
|
|
||||||
|
|
||||||
alc.shortcut(
|
alc.shortcut(
|
||||||
@@ -130,11 +140,11 @@ alc.shortcut(
|
|||||||
command='tstats TETR.IO bind',
|
command='tstats TETR.IO bind',
|
||||||
humanized='io绑定',
|
humanized='io绑定',
|
||||||
)
|
)
|
||||||
alc.shortcut(
|
# alc.shortcut(
|
||||||
'(?i:io)(?i:查询|查|query|stats)',
|
# '(?i:io)(?i:查询|查|query|stats)',
|
||||||
command='tstats TETR.IO query',
|
# command='tstats TETR.IO query',
|
||||||
humanized='io查',
|
# humanized='io查',
|
||||||
)
|
# )
|
||||||
alc.shortcut(
|
alc.shortcut(
|
||||||
'(?i:io)(?i:记录|record)(?i:40l)',
|
'(?i:io)(?i:记录|record)(?i:40l)',
|
||||||
command='tstats TETR.IO record --40l',
|
command='tstats TETR.IO record --40l',
|
||||||
@@ -145,36 +155,37 @@ alc.shortcut(
|
|||||||
command='tstats TETR.IO record --blitz',
|
command='tstats TETR.IO record --blitz',
|
||||||
humanized='io记录blitz',
|
humanized='io记录blitz',
|
||||||
)
|
)
|
||||||
alc.shortcut(
|
# alc.shortcut(
|
||||||
r'(?i:io)(?i:段位|段|rank)\s*(?P<rank>[a-zA-Z+-]{0,2})',
|
# r'(?i:io)(?i:段位|段|rank)\s*(?P<rank>[a-zA-Z+-]{0,2})',
|
||||||
command='tstats TETR.IO rank {rank}',
|
# command='tstats TETR.IO rank {rank}',
|
||||||
humanized='iorank',
|
# humanized='iorank',
|
||||||
fuzzy=False,
|
# fuzzy=False,
|
||||||
wrapper=rank_wrapper,
|
# wrapper=rank_wrapper,
|
||||||
)
|
# )
|
||||||
alc.shortcut(
|
alc.shortcut(
|
||||||
'(?i:io)(?i:配置|配|config)',
|
'(?i:io)(?i:配置|配|config)',
|
||||||
command='tstats TETR.IO config',
|
command='tstats TETR.IO config',
|
||||||
humanized='io配置',
|
humanized='io配置',
|
||||||
)
|
)
|
||||||
|
|
||||||
alc.shortcut(
|
# alc.shortcut(
|
||||||
'fkosk',
|
# 'fkosk',
|
||||||
command='tstats TETR.IO query',
|
# command='tstats TETR.IO query',
|
||||||
arguments=['我'],
|
# arguments=['我'],
|
||||||
fuzzy=False,
|
# fuzzy=False,
|
||||||
humanized='An Easter egg!',
|
# humanized='An Easter egg!',
|
||||||
)
|
# )
|
||||||
|
|
||||||
add_block_handlers(alc.assign('TETRIO.query'))
|
# add_block_handlers(alc.assign('TETRIO.query'))
|
||||||
|
|
||||||
from . import bind, config, list, query, rank, record # noqa: E402
|
# from . import bind, config, list, query, rank, record
|
||||||
|
from . import bind, config, record # noqa: E402
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'bind',
|
'bind',
|
||||||
'config',
|
'config',
|
||||||
'list',
|
# 'list',
|
||||||
'query',
|
# 'query',
|
||||||
'rank',
|
# 'rank',
|
||||||
'record',
|
'record',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
|
|||||||
|
|
||||||
from ....db.models import PydanticType
|
from ....db.models import PydanticType
|
||||||
from .schemas.base import SuccessModel
|
from .schemas.base import SuccessModel
|
||||||
|
from .typing import Summaries
|
||||||
|
|
||||||
|
|
||||||
class TETRIOHistoricalData(MappedAsDataclass, Model):
|
class TETRIOHistoricalData(MappedAsDataclass, Model):
|
||||||
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
||||||
user_unique_identifier: Mapped[str] = mapped_column(String(24), index=True)
|
user_unique_identifier: Mapped[str] = mapped_column(String(24), index=True)
|
||||||
api_type: Mapped[Literal['User Info', 'User Records']] = mapped_column(String(16), index=True)
|
api_type: Mapped[Literal['User Info', Summaries]] = mapped_column(String(16), index=True)
|
||||||
data: Mapped[SuccessModel] = mapped_column(PydanticType(get_model=[SuccessModel.__subclasses__], models=set()))
|
data: Mapped[SuccessModel] = mapped_column(PydanticType(get_model=[SuccessModel.__subclasses__], models=set()))
|
||||||
update_time: Mapped[datetime] = mapped_column(DateTime, index=True)
|
update_time: Mapped[datetime] = mapped_column(DateTime, index=True)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from typing import overload
|
from types import MappingProxyType
|
||||||
|
from typing import Literal, overload
|
||||||
|
|
||||||
|
from async_lru import alru_cache
|
||||||
from nonebot.compat import type_validate_json
|
from nonebot.compat import type_validate_json
|
||||||
|
|
||||||
from ....db import anti_duplicate_add
|
from ....db import anti_duplicate_add
|
||||||
@@ -9,12 +11,31 @@ from ..constant import BASE_URL, USER_ID, USER_NAME
|
|||||||
from .cache import Cache
|
from .cache import Cache
|
||||||
from .models import TETRIOHistoricalData
|
from .models import TETRIOHistoricalData
|
||||||
from .schemas.base import FailedModel
|
from .schemas.base import FailedModel
|
||||||
|
from .schemas.summaries import (
|
||||||
|
AchievementsSuccessModel,
|
||||||
|
SoloSuccessModel,
|
||||||
|
SummariesModel,
|
||||||
|
ZenithSuccessModel,
|
||||||
|
ZenSuccessModel,
|
||||||
|
)
|
||||||
|
from .schemas.summaries.base import User as SummariesUser
|
||||||
from .schemas.user import User
|
from .schemas.user import User
|
||||||
from .schemas.user_info import UserInfo, UserInfoSuccess
|
from .schemas.user_info import UserInfo, UserInfoSuccess
|
||||||
from .schemas.user_records import SoloModeRecord, UserRecords, UserRecordsSuccess, Zen
|
from .typing import Summaries
|
||||||
|
|
||||||
|
|
||||||
class Player:
|
class Player:
|
||||||
|
__SUMMARIES_MAPPING: MappingProxyType[Summaries, type[SummariesModel]] = MappingProxyType(
|
||||||
|
{
|
||||||
|
'40l': SoloSuccessModel,
|
||||||
|
'blitz': SoloSuccessModel,
|
||||||
|
'zenith': ZenithSuccessModel,
|
||||||
|
'zenithex': ZenithSuccessModel,
|
||||||
|
'zen': ZenSuccessModel,
|
||||||
|
'achievements': AchievementsSuccessModel,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def __init__(self, *, user_id: str, trust: bool = False): ...
|
def __init__(self, *, user_id: str, trust: bool = False): ...
|
||||||
@overload
|
@overload
|
||||||
@@ -36,7 +57,7 @@ class Player:
|
|||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
self.__user: User | None = None
|
self.__user: User | None = None
|
||||||
self._user_info: UserInfoSuccess | None = None
|
self._user_info: UserInfoSuccess | None = None
|
||||||
self._user_records: UserRecordsSuccess | None = None
|
self._summaries: dict[Summaries, SummariesModel] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _request_user_parameter(self) -> str:
|
def _request_user_parameter(self) -> str:
|
||||||
@@ -49,14 +70,21 @@ class Player:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
async def user(self) -> User:
|
async def user(self) -> User:
|
||||||
if self.__user is None:
|
if self.__user is not None:
|
||||||
|
return self.__user
|
||||||
|
if (user := (await self._get_local_summaries_user())) is not None:
|
||||||
|
self.__user = User(
|
||||||
|
ID=user.id,
|
||||||
|
name=user.username,
|
||||||
|
)
|
||||||
|
else:
|
||||||
user_info = await self.get_info()
|
user_info = await self.get_info()
|
||||||
self.__user = User(
|
self.__user = User(
|
||||||
ID=user_info.data.user.id,
|
ID=user_info.data.id,
|
||||||
name=user_info.data.user.username,
|
name=user_info.data.username,
|
||||||
)
|
)
|
||||||
self.user_id = user_info.data.user.id
|
self.user_id = self.__user.ID
|
||||||
self.user_name = user_info.data.user.username
|
self.user_name = self.__user.name
|
||||||
return self.__user
|
return self.__user
|
||||||
|
|
||||||
async def get_info(self) -> UserInfoSuccess:
|
async def get_info(self) -> UserInfoSuccess:
|
||||||
@@ -79,36 +107,81 @@ class Player:
|
|||||||
)
|
)
|
||||||
return self._user_info
|
return self._user_info
|
||||||
|
|
||||||
async def get_records(self) -> UserRecordsSuccess:
|
@overload
|
||||||
"""Get User Records"""
|
async def get_summaries(self, summaries_type: Literal['40l', 'blitz']) -> SoloSuccessModel: ...
|
||||||
if self._user_records is None:
|
@overload
|
||||||
raw_user_records = await Cache.get(
|
async def get_summaries(self, summaries_type: Literal['zenith', 'zenithex']) -> ZenithSuccessModel: ...
|
||||||
splice_url([BASE_URL, 'users/', f'{self._request_user_parameter}/', 'records'])
|
@overload
|
||||||
|
async def get_summaries(self, summaries_type: Literal['zen']) -> ZenSuccessModel: ...
|
||||||
|
@overload
|
||||||
|
async def get_summaries(self, summaries_type: Literal['achievements']) -> AchievementsSuccessModel: ...
|
||||||
|
|
||||||
|
async def get_summaries(self, summaries_type: Summaries) -> SummariesModel:
|
||||||
|
if summaries_type not in self._summaries:
|
||||||
|
raw_summaries = await Cache.get(
|
||||||
|
splice_url([BASE_URL, 'users/', f'{self._request_user_parameter}/', 'summaries/', summaries_type])
|
||||||
)
|
)
|
||||||
user_records: UserRecords = type_validate_json(UserRecords, raw_user_records) # type: ignore[arg-type]
|
summaries: SummariesModel | FailedModel = type_validate_json(
|
||||||
if isinstance(user_records, FailedModel):
|
self.__SUMMARIES_MAPPING[summaries_type] | FailedModel, # type: ignore[arg-type]
|
||||||
msg = f'用户Solo数据请求错误:\n{user_records.error}'
|
raw_summaries,
|
||||||
|
)
|
||||||
|
if isinstance(summaries, FailedModel):
|
||||||
|
msg = f'用户Summaries数据请求错误:\n{summaries.error}'
|
||||||
raise RequestError(msg)
|
raise RequestError(msg)
|
||||||
self._user_records = user_records
|
self._summaries[summaries_type] = summaries
|
||||||
await anti_duplicate_add(
|
await anti_duplicate_add(
|
||||||
TETRIOHistoricalData,
|
TETRIOHistoricalData,
|
||||||
TETRIOHistoricalData(
|
TETRIOHistoricalData(
|
||||||
user_unique_identifier=(await self.user).unique_identifier,
|
user_unique_identifier=(await self.user).unique_identifier,
|
||||||
api_type='User Records',
|
api_type=summaries_type,
|
||||||
data=user_records,
|
data=summaries,
|
||||||
update_time=user_records.cache.cached_at,
|
update_time=summaries.cache.cached_at,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return self._user_records
|
return self._summaries[summaries_type]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
async def sprint(self) -> SoloModeRecord:
|
@alru_cache
|
||||||
return (await self.get_records()).data.records.sprint
|
async def sprint(self) -> SoloSuccessModel:
|
||||||
|
return await self.get_summaries('40l')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
async def blitz(self) -> SoloModeRecord:
|
@alru_cache
|
||||||
return (await self.get_records()).data.records.blitz
|
async def blitz(self) -> SoloSuccessModel:
|
||||||
|
return await self.get_summaries('blitz')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
async def zen(self) -> Zen:
|
@alru_cache
|
||||||
return (await self.get_records()).data.zen
|
async def zen(self) -> ZenSuccessModel:
|
||||||
|
return await self.get_summaries('zen')
|
||||||
|
|
||||||
|
async def _get_local_summaries_user(self) -> SummariesUser | None:
|
||||||
|
allow_summaries: set[Literal['40l', 'blitz', 'zenith', 'zenithex']] = {
|
||||||
|
'40l',
|
||||||
|
'blitz',
|
||||||
|
'zenith',
|
||||||
|
'zenithex',
|
||||||
|
}
|
||||||
|
if has_summaries := (allow_summaries & self._summaries.keys()):
|
||||||
|
for i in has_summaries:
|
||||||
|
if (record := (await self.get_summaries(i)).data.record) is not None:
|
||||||
|
return record.user
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
@alru_cache
|
||||||
|
async def avatar_revision(self) -> int | None:
|
||||||
|
if self._user_info is not None:
|
||||||
|
return self._user_info.data.avatar_revision
|
||||||
|
if (user := (await self._get_local_summaries_user())) is not None:
|
||||||
|
return user.avatar_revision
|
||||||
|
return (await self.get_info()).data.avatar_revision
|
||||||
|
|
||||||
|
@property
|
||||||
|
@alru_cache
|
||||||
|
async def banner_revision(self) -> int | None:
|
||||||
|
if self._user_info is not None:
|
||||||
|
return self._user_info.data.banner_revision
|
||||||
|
if (user := (await self._get_local_summaries_user())) is not None:
|
||||||
|
return user.banner_revision
|
||||||
|
return (await self.get_info()).data.banner_revision
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ from typing import Literal
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class P(BaseModel): # what is P
|
||||||
|
pri: float
|
||||||
|
sec: float
|
||||||
|
ter: float
|
||||||
|
|
||||||
|
|
||||||
class Cache(BaseModel):
|
class Cache(BaseModel):
|
||||||
status: str
|
status: str
|
||||||
cached_at: datetime
|
cached_at: datetime
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from ..base import SuccessModel
|
||||||
|
from .base import Entry as BaseEntry
|
||||||
|
|
||||||
|
|
||||||
|
class ArCounts(BaseModel):
|
||||||
|
bronze: int | None = Field(None, alias='1')
|
||||||
|
silver: int | None = Field(None, alias='2')
|
||||||
|
gold: int | None = Field(None, alias='3')
|
||||||
|
platinum: int | None = Field(None, alias='4')
|
||||||
|
diamond: int | None = Field(None, alias='5')
|
||||||
|
issued: int | None = Field(None, alias='100')
|
||||||
|
top10: int | None = Field(None, alias='t10')
|
||||||
|
|
||||||
|
|
||||||
|
class Entry(BaseEntry):
|
||||||
|
ar: int
|
||||||
|
ar_counts: ArCounts
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
entries: list[Entry]
|
||||||
|
|
||||||
|
|
||||||
|
class ArSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from ...typing import Rank
|
||||||
|
from ..base import P
|
||||||
|
|
||||||
|
|
||||||
|
class League(BaseModel):
|
||||||
|
gamesplayed: int
|
||||||
|
gameswon: int
|
||||||
|
rating: int
|
||||||
|
rank: Rank
|
||||||
|
decaying: bool
|
||||||
|
|
||||||
|
|
||||||
|
class Entry(BaseModel):
|
||||||
|
id: str = Field(..., alias='_id')
|
||||||
|
username: str
|
||||||
|
role: str
|
||||||
|
xp: float
|
||||||
|
league: League
|
||||||
|
supporter: bool | None = None
|
||||||
|
verified: bool
|
||||||
|
country: str | None = None
|
||||||
|
ts: datetime
|
||||||
|
gamesplayed: int
|
||||||
|
gameswon: int
|
||||||
|
gametime: float
|
||||||
|
p: P
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from ..base import SuccessModel
|
||||||
|
from ..summaries.solo import Record
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
entries: list[Record]
|
||||||
|
|
||||||
|
|
||||||
|
class SoloSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from ..base import SuccessModel
|
||||||
|
from .base import Entry
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
entries: list[Entry]
|
||||||
|
|
||||||
|
|
||||||
|
class XpSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from ..base import SuccessModel
|
||||||
|
from ..summaries.zenith import Record
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
entries: list[Record]
|
||||||
|
|
||||||
|
|
||||||
|
class ZenithSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from .achievements import Achievements, AchievementsSuccessModel
|
||||||
|
from .solo import Blitz, SoloSuccessModel, Sprint
|
||||||
|
from .zen import Zen, ZenSuccessModel
|
||||||
|
from .zenith import Zenith, ZenithEx, ZenithSuccessModel
|
||||||
|
|
||||||
|
SummariesModel = AchievementsSuccessModel | SoloSuccessModel | ZenSuccessModel | ZenithSuccessModel
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'Achievements',
|
||||||
|
'AchievementsSuccessModel',
|
||||||
|
'Blitz',
|
||||||
|
'Sprint',
|
||||||
|
'SoloSuccessModel',
|
||||||
|
'Zen',
|
||||||
|
'ZenSuccessModel',
|
||||||
|
'Zenith',
|
||||||
|
'ZenithEx',
|
||||||
|
'ZenithSuccessModel',
|
||||||
|
'SummariesModel',
|
||||||
|
]
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
from typing import TypeAlias
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from ..base import FailedModel, SuccessModel
|
||||||
|
|
||||||
|
|
||||||
|
class Achievement(BaseModel):
|
||||||
|
# 这**都是些啥
|
||||||
|
k: int
|
||||||
|
o: int
|
||||||
|
rt: int
|
||||||
|
vt: int
|
||||||
|
min: int
|
||||||
|
deci: int
|
||||||
|
name: str
|
||||||
|
object: str
|
||||||
|
category: str
|
||||||
|
hidden: bool
|
||||||
|
desc: str
|
||||||
|
n: str
|
||||||
|
stub: bool
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementsSuccessModel(SuccessModel):
|
||||||
|
data: list[Achievement]
|
||||||
|
|
||||||
|
|
||||||
|
Achievements: TypeAlias = AchievementsSuccessModel | FailedModel
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class User(BaseModel):
|
||||||
|
id: str
|
||||||
|
username: str
|
||||||
|
avatar_revision: int | None
|
||||||
|
banner_revision: int | None
|
||||||
|
country: str | None
|
||||||
|
verified: int
|
||||||
|
supporter: int
|
||||||
|
|
||||||
|
|
||||||
|
class AggregateStats(BaseModel):
|
||||||
|
apm: float
|
||||||
|
pps: float
|
||||||
|
vsscore: float
|
||||||
|
|
||||||
|
|
||||||
|
class Finesse(BaseModel):
|
||||||
|
combo: int
|
||||||
|
faults: int
|
||||||
|
perfectpieces: int
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Literal, TypeAlias
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from ..base import FailedModel, P, SuccessModel
|
||||||
|
from .base import AggregateStats, Finesse, User
|
||||||
|
|
||||||
|
|
||||||
|
class Time(BaseModel):
|
||||||
|
start: int
|
||||||
|
zero: bool
|
||||||
|
locked: bool
|
||||||
|
prev: int
|
||||||
|
frameoffset: int
|
||||||
|
|
||||||
|
|
||||||
|
class Clears(BaseModel):
|
||||||
|
singles: int
|
||||||
|
doubles: int
|
||||||
|
triples: int
|
||||||
|
quads: int
|
||||||
|
realtspins: int
|
||||||
|
minitspins: int
|
||||||
|
minitspinsingles: int
|
||||||
|
tspinsingles: int
|
||||||
|
minitspindoubles: int
|
||||||
|
tspindoubles: int
|
||||||
|
tspintriples: int
|
||||||
|
tspinquads: int
|
||||||
|
allclear: int
|
||||||
|
|
||||||
|
|
||||||
|
class Garbage(BaseModel):
|
||||||
|
sent: int
|
||||||
|
received: int
|
||||||
|
attack: int | None
|
||||||
|
cleared: int
|
||||||
|
|
||||||
|
|
||||||
|
class Stats(BaseModel):
|
||||||
|
seed: int
|
||||||
|
lines: int
|
||||||
|
level_lines: int
|
||||||
|
level_lines_needed: int
|
||||||
|
inputs: int
|
||||||
|
holds: int
|
||||||
|
time: Time
|
||||||
|
score: int
|
||||||
|
zenlevel: int
|
||||||
|
zenprogress: int
|
||||||
|
level: int
|
||||||
|
combo: int
|
||||||
|
currentcombopower: int | None = None
|
||||||
|
topcombo: int
|
||||||
|
btb: int
|
||||||
|
topbtb: int
|
||||||
|
currentbtbchainpower: int | None = None
|
||||||
|
tspins: int
|
||||||
|
piecesplaced: int
|
||||||
|
clears: Clears
|
||||||
|
garbage: Garbage
|
||||||
|
kills: int
|
||||||
|
finesse: Finesse
|
||||||
|
finaltime: float
|
||||||
|
|
||||||
|
|
||||||
|
class Results(BaseModel):
|
||||||
|
aggregatestats: AggregateStats
|
||||||
|
stats: Stats
|
||||||
|
gameoverreason: str
|
||||||
|
|
||||||
|
|
||||||
|
class Record(BaseModel):
|
||||||
|
id: str = Field(..., alias='_id')
|
||||||
|
replayid: str
|
||||||
|
stub: bool
|
||||||
|
gamemode: Literal['40l', 'blitz']
|
||||||
|
pb: bool
|
||||||
|
oncepb: bool
|
||||||
|
ts: datetime
|
||||||
|
revolution: None
|
||||||
|
user: User
|
||||||
|
otherusers: list
|
||||||
|
leaderboards: list[str]
|
||||||
|
results: Results
|
||||||
|
extras: dict
|
||||||
|
disputed: bool
|
||||||
|
p: P
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
record: Record | None
|
||||||
|
rank: int
|
||||||
|
rank_local: int
|
||||||
|
|
||||||
|
|
||||||
|
class SoloSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
|
|
||||||
|
|
||||||
|
Sprint: TypeAlias = SoloSuccessModel | FailedModel
|
||||||
|
Blitz: TypeAlias = SoloSuccessModel | FailedModel
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from typing import TypeAlias
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from ..base import FailedModel, SuccessModel
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
level: int
|
||||||
|
score: int
|
||||||
|
|
||||||
|
|
||||||
|
class ZenSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
|
|
||||||
|
|
||||||
|
Zen: TypeAlias = ZenSuccessModel | FailedModel
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Literal, TypeAlias
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from ..base import FailedModel, P, SuccessModel
|
||||||
|
from .base import AggregateStats, Finesse, User
|
||||||
|
|
||||||
|
|
||||||
|
class Clears(BaseModel):
|
||||||
|
singles: int
|
||||||
|
doubles: int
|
||||||
|
triples: int
|
||||||
|
quads: int
|
||||||
|
pentas: int
|
||||||
|
realtspins: int
|
||||||
|
minitspins: int
|
||||||
|
minitspinsingles: int
|
||||||
|
tspinsingles: int
|
||||||
|
minitspindoubles: int
|
||||||
|
tspindoubles: int
|
||||||
|
minitspintriples: int
|
||||||
|
tspintriples: int
|
||||||
|
minitspinquads: int
|
||||||
|
tspinquads: int
|
||||||
|
tspinpentas: int
|
||||||
|
allclear: int
|
||||||
|
|
||||||
|
|
||||||
|
class Garbage(BaseModel):
|
||||||
|
sent: int
|
||||||
|
sent_nomult: int
|
||||||
|
maxspike: int
|
||||||
|
maxspike_nomult: int
|
||||||
|
received: int
|
||||||
|
attack: int
|
||||||
|
cleared: int
|
||||||
|
|
||||||
|
|
||||||
|
class _Zenith(BaseModel):
|
||||||
|
altitude: float
|
||||||
|
rank: float
|
||||||
|
peakrank: float
|
||||||
|
avgrankpts: float
|
||||||
|
floor: int
|
||||||
|
targetingfactor: float
|
||||||
|
targetinggrace: float
|
||||||
|
totalbonus: float
|
||||||
|
revives: int
|
||||||
|
revives_total: int = Field(..., alias='revivesTotal')
|
||||||
|
speedrun: bool
|
||||||
|
speedrun_seen: bool
|
||||||
|
splits: list[int]
|
||||||
|
|
||||||
|
|
||||||
|
class Stats(BaseModel):
|
||||||
|
lines: int
|
||||||
|
level_lines: int
|
||||||
|
level_lines_needed: int
|
||||||
|
inputs: int
|
||||||
|
holds: int
|
||||||
|
score: int
|
||||||
|
zenlevel: int
|
||||||
|
zenprogress: int
|
||||||
|
level: int
|
||||||
|
combo: int
|
||||||
|
topcombo: int
|
||||||
|
combopower: int
|
||||||
|
btb: int
|
||||||
|
topbtb: int
|
||||||
|
btbpower: int
|
||||||
|
tspins: int
|
||||||
|
piecesplaced: int
|
||||||
|
clears: Clears
|
||||||
|
garbage: Garbage
|
||||||
|
kills: int
|
||||||
|
finesse: Finesse
|
||||||
|
zenith: _Zenith
|
||||||
|
finaltime: float
|
||||||
|
|
||||||
|
|
||||||
|
class Results(BaseModel):
|
||||||
|
aggregatestats: AggregateStats
|
||||||
|
stats: Stats
|
||||||
|
gameoverreason: str
|
||||||
|
|
||||||
|
|
||||||
|
class ExtrasZenith(BaseModel):
|
||||||
|
mods: list[str]
|
||||||
|
|
||||||
|
|
||||||
|
class Extras(BaseModel):
|
||||||
|
zenith: ExtrasZenith
|
||||||
|
|
||||||
|
|
||||||
|
class Record(BaseModel):
|
||||||
|
id: str = Field(..., alias='_id')
|
||||||
|
replayid: str
|
||||||
|
stub: bool
|
||||||
|
gamemode: Literal['zenith', 'zenithex']
|
||||||
|
pb: bool
|
||||||
|
oncepb: bool
|
||||||
|
ts: datetime
|
||||||
|
revolution: None
|
||||||
|
user: User
|
||||||
|
otherusers: list
|
||||||
|
leaderboards: list[str]
|
||||||
|
results: Results
|
||||||
|
extras: Extras
|
||||||
|
disputed: bool
|
||||||
|
p: P
|
||||||
|
|
||||||
|
|
||||||
|
class Best(BaseModel):
|
||||||
|
record: None # WTF
|
||||||
|
rank: int
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
record: Record | None
|
||||||
|
rank: int
|
||||||
|
rank_local: int
|
||||||
|
best: Best
|
||||||
|
|
||||||
|
|
||||||
|
class ZenithSuccessModel(SuccessModel):
|
||||||
|
data: Data
|
||||||
|
|
||||||
|
|
||||||
|
Zenith: TypeAlias = ZenithSuccessModel | FailedModel
|
||||||
|
ZenithEx: TypeAlias = ZenithSuccessModel | FailedModel
|
||||||
@@ -3,7 +3,6 @@ from typing import Literal
|
|||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from ..typing import Rank
|
|
||||||
from .base import FailedModel
|
from .base import FailedModel
|
||||||
from .base import SuccessModel as BaseSuccessModel
|
from .base import SuccessModel as BaseSuccessModel
|
||||||
|
|
||||||
@@ -15,67 +14,6 @@ class Badge(BaseModel):
|
|||||||
ts: datetime | Literal[False] | None = None
|
ts: datetime | Literal[False] | None = None
|
||||||
|
|
||||||
|
|
||||||
class MetaLeague(BaseModel):
|
|
||||||
decaying: bool
|
|
||||||
|
|
||||||
|
|
||||||
class NeverPlayedLeague(MetaLeague):
|
|
||||||
gamesplayed: Literal[0]
|
|
||||||
gameswon: Literal[0]
|
|
||||||
rating: Literal[-1]
|
|
||||||
rank: Literal['z']
|
|
||||||
standing: Literal[-1]
|
|
||||||
standing_local: Literal[-1]
|
|
||||||
next_rank: None
|
|
||||||
prev_rank: None
|
|
||||||
next_at: Literal[-1]
|
|
||||||
prev_at: Literal[-1]
|
|
||||||
percentile: Literal[-1]
|
|
||||||
percentile_rank: Literal['z']
|
|
||||||
apm: None = None
|
|
||||||
pps: None = None
|
|
||||||
vs: None = None
|
|
||||||
|
|
||||||
|
|
||||||
class NeverRatedLeague(MetaLeague):
|
|
||||||
gamesplayed: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
||||||
gameswon: int
|
|
||||||
rating: Literal[-1]
|
|
||||||
rank: Literal['z']
|
|
||||||
standing: Literal[-1]
|
|
||||||
standing_local: Literal[-1]
|
|
||||||
next_rank: None
|
|
||||||
prev_rank: None
|
|
||||||
next_at: Literal[-1]
|
|
||||||
prev_at: Literal[-1]
|
|
||||||
percentile: Literal[-1]
|
|
||||||
percentile_rank: Literal['z']
|
|
||||||
apm: float
|
|
||||||
pps: float
|
|
||||||
vs: float | None = None
|
|
||||||
|
|
||||||
|
|
||||||
class RatedLeague(MetaLeague):
|
|
||||||
gamesplayed: int
|
|
||||||
gameswon: int
|
|
||||||
rating: float
|
|
||||||
rank: Rank
|
|
||||||
bestrank: Rank
|
|
||||||
standing: int
|
|
||||||
standing_local: int
|
|
||||||
next_rank: Rank | None = None
|
|
||||||
prev_rank: Rank | None = None
|
|
||||||
next_at: int
|
|
||||||
prev_at: int
|
|
||||||
percentile: float
|
|
||||||
percentile_rank: str
|
|
||||||
glicko: float
|
|
||||||
rd: float
|
|
||||||
apm: float
|
|
||||||
pps: float
|
|
||||||
vs: float | None = None
|
|
||||||
|
|
||||||
|
|
||||||
class Discord(BaseModel):
|
class Discord(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
username: str
|
username: str
|
||||||
@@ -89,7 +27,7 @@ class Distinguishment(BaseModel):
|
|||||||
type: str
|
type: str
|
||||||
|
|
||||||
|
|
||||||
class User(BaseModel):
|
class Data(BaseModel):
|
||||||
id: str = Field(..., alias='_id')
|
id: str = Field(..., alias='_id')
|
||||||
username: str
|
username: str
|
||||||
role: Literal['anon', 'user', 'bot', 'halfmod', 'mod', 'admin', 'sysop', 'banned']
|
role: Literal['anon', 'user', 'bot', 'halfmod', 'mod', 'admin', 'sysop', 'banned']
|
||||||
@@ -105,7 +43,6 @@ class User(BaseModel):
|
|||||||
supporter: bool | None = None # osk说是必有, 但实际上不是 fkosk
|
supporter: bool | None = None # osk说是必有, 但实际上不是 fkosk
|
||||||
supporter_tier: int
|
supporter_tier: int
|
||||||
verified: bool
|
verified: bool
|
||||||
league: NeverPlayedLeague | NeverRatedLeague | RatedLeague
|
|
||||||
avatar_revision: int | None = None
|
avatar_revision: int | None = None
|
||||||
"""This user's avatar ID. Get their avatar at
|
"""This user's avatar ID. Get their avatar at
|
||||||
|
|
||||||
@@ -122,10 +59,6 @@ class User(BaseModel):
|
|||||||
distinguishment: Distinguishment | None = None
|
distinguishment: Distinguishment | None = None
|
||||||
|
|
||||||
|
|
||||||
class Data(BaseModel):
|
|
||||||
user: User
|
|
||||||
|
|
||||||
|
|
||||||
class UserInfoSuccess(BaseSuccessModel):
|
class UserInfoSuccess(BaseSuccessModel):
|
||||||
data: Data
|
data: Data
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,13 @@ ValidRank = Literal[
|
|||||||
]
|
]
|
||||||
|
|
||||||
Rank = ValidRank | Literal['z'] # 未定级
|
Rank = ValidRank | Literal['z'] # 未定级
|
||||||
|
|
||||||
|
Summaries = Literal[
|
||||||
|
'40l',
|
||||||
|
'blitz',
|
||||||
|
'zenith',
|
||||||
|
'zenithex',
|
||||||
|
# 'league', # 等待正式赛季开始
|
||||||
|
'zen',
|
||||||
|
'achievements',
|
||||||
|
]
|
||||||
|
|||||||
@@ -45,11 +45,10 @@ async def _(nb_user: User, account: Player, event_session: EventSession, bot_inf
|
|||||||
platform='TETR.IO',
|
platform='TETR.IO',
|
||||||
status='unknown',
|
status='unknown',
|
||||||
user=People(
|
user=People(
|
||||||
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": user_info.data.user.avatar_revision})}'
|
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": avatar_revision})}'
|
||||||
if user_info.data.user.avatar_revision is not None
|
if (avatar_revision := (await account.avatar_revision)) is not None and avatar_revision != 0
|
||||||
and user_info.data.user.avatar_revision != 0
|
else Avatar(type='identicon', hash=md5(user.ID.encode()).hexdigest()), # noqa: S324
|
||||||
else Avatar(type='identicon', hash=md5(user_info.data.user.id.encode()).hexdigest()), # noqa: S324
|
name=user.name.upper(),
|
||||||
name=user_info.data.user.username.upper(),
|
|
||||||
),
|
),
|
||||||
bot=People(
|
bot=People(
|
||||||
avatar=await get_avatar(bot_info, 'Data URI', '../../static/logo/logo.svg'),
|
avatar=await get_avatar(bot_info, 'Data URI', '../../static/logo/logo.svg'),
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_session_orm import get_session_persist_id # type: ignore[import-untyped]
|
|
||||||
|
|
||||||
from ...db import trigger
|
|
||||||
from ...utils.host import HostPage, get_self_netloc
|
|
||||||
from ...utils.metrics import get_metrics
|
|
||||||
from ...utils.render import render
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_user_list_v2 import List, TetraLeague, User
|
|
||||||
from ...utils.screenshot import screenshot
|
|
||||||
from .. import alc
|
|
||||||
from .api.schemas.tetra_league import ValidLeague
|
|
||||||
from .api.tetra_league import Parameter, leaderboard
|
|
||||||
from .constant import GAME_TYPE
|
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.list')
|
|
||||||
async def _(
|
|
||||||
event_session: EventSession,
|
|
||||||
max_tr: float | None = None,
|
|
||||||
min_tr: float | None = None,
|
|
||||||
limit: int | None = None,
|
|
||||||
country: str | None = None,
|
|
||||||
):
|
|
||||||
async with trigger(
|
|
||||||
session_persist_id=await get_session_persist_id(event_session),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
command_type='list',
|
|
||||||
command_args=[
|
|
||||||
f'{key} {value}'
|
|
||||||
for key, value in zip(
|
|
||||||
('--max-tr', '--min-tr', '--limit', '--country'), (max_tr, min_tr, limit, country), strict=True
|
|
||||||
)
|
|
||||||
if value is not None
|
|
||||||
],
|
|
||||||
):
|
|
||||||
parameter: Parameter = {}
|
|
||||||
if max_tr is not None:
|
|
||||||
parameter['after'] = max_tr
|
|
||||||
if min_tr is not None:
|
|
||||||
parameter['before'] = min_tr
|
|
||||||
if limit is not None:
|
|
||||||
parameter['limit'] = limit
|
|
||||||
if country is not None:
|
|
||||||
parameter['country'] = country
|
|
||||||
league = await leaderboard(parameter)
|
|
||||||
async with HostPage(
|
|
||||||
await render(
|
|
||||||
'v2/tetrio/user/list',
|
|
||||||
List(
|
|
||||||
show_index=True,
|
|
||||||
users=[
|
|
||||||
User(
|
|
||||||
id=i.id,
|
|
||||||
name=i.username.upper(),
|
|
||||||
avatar=f'https://tetr.io/user-content/avatars/{i.id}.jpg',
|
|
||||||
country=i.country,
|
|
||||||
verified=i.verified,
|
|
||||||
tetra_league=TetraLeague(
|
|
||||||
rank=i.league.rank,
|
|
||||||
tr=round(i.league.rating, 2),
|
|
||||||
glicko=round(i.league.glicko, 2),
|
|
||||||
rd=round(i.league.rd, 2),
|
|
||||||
decaying=i.league.decaying,
|
|
||||||
pps=(metrics := get_metrics(pps=i.league.pps, apm=i.league.apm, vs=i.league.vs)).pps,
|
|
||||||
apm=metrics.apm,
|
|
||||||
apl=metrics.apl,
|
|
||||||
vs=metrics.vs,
|
|
||||||
adpl=metrics.adpl,
|
|
||||||
),
|
|
||||||
xp=i.xp,
|
|
||||||
join_at=None,
|
|
||||||
)
|
|
||||||
for i in league.data.users
|
|
||||||
if isinstance(i.league, ValidLeague)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
) as page_hash:
|
|
||||||
await UniMessage.image(raw=await screenshot(f'http://{get_self_netloc()}/host/{page_hash}.html')).finish()
|
|
||||||
@@ -1,34 +1,10 @@
|
|||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from nonebot_plugin_orm import Model
|
from nonebot_plugin_orm import Model
|
||||||
from sqlalchemy import JSON, DateTime, String
|
from sqlalchemy import String
|
||||||
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
|
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
|
||||||
|
|
||||||
from .api.typing import ValidRank
|
|
||||||
from .typing import Template
|
from .typing import Template
|
||||||
|
|
||||||
|
|
||||||
class IORank(MappedAsDataclass, Model):
|
|
||||||
id: Mapped[int] = mapped_column(init=False, primary_key=True)
|
|
||||||
rank: Mapped[ValidRank] = mapped_column(String(2), index=True)
|
|
||||||
tr_line: Mapped[float]
|
|
||||||
player_count: Mapped[int]
|
|
||||||
low_pps: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
low_apm: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
low_vs: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
avg_pps: Mapped[float]
|
|
||||||
avg_apm: Mapped[float]
|
|
||||||
avg_vs: Mapped[float]
|
|
||||||
high_pps: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
high_apm: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
high_vs: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
|
|
||||||
update_time: Mapped[datetime] = mapped_column(
|
|
||||||
DateTime,
|
|
||||||
index=True,
|
|
||||||
)
|
|
||||||
file_hash: Mapped[str | None] = mapped_column(String(128), index=True)
|
|
||||||
|
|
||||||
|
|
||||||
class TETRIOUserConfig(MappedAsDataclass, Model):
|
class TETRIOUserConfig(MappedAsDataclass, Model):
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
query_template: Mapped[Template] = mapped_column(String(2))
|
query_template: Mapped[Template] = mapped_column(String(2))
|
||||||
|
|||||||
@@ -1,554 +0,0 @@
|
|||||||
from asyncio import gather
|
|
||||||
from collections import defaultdict
|
|
||||||
from datetime import date, datetime, timedelta, timezone
|
|
||||||
from hashlib import md5
|
|
||||||
from math import ceil, floor
|
|
||||||
from typing import ClassVar, TypeVar, overload
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
from zoneinfo import ZoneInfo
|
|
||||||
|
|
||||||
from aiofiles import open
|
|
||||||
from nonebot import get_driver
|
|
||||||
from nonebot.adapters import Event
|
|
||||||
from nonebot.compat import type_validate_json
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot_plugin_alconna import At
|
|
||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
|
||||||
from nonebot_plugin_apscheduler import scheduler # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_localstore import get_data_file # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_orm import get_session
|
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_session_orm import get_session_persist_id # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_user import User as NBUser # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_user import get_user # type: ignore[import-untyped]
|
|
||||||
from sqlalchemy import select
|
|
||||||
from zstandard import ZstdDecompressor
|
|
||||||
|
|
||||||
from ...db import query_bind_info, trigger
|
|
||||||
from ...utils.exception import FallbackError
|
|
||||||
from ...utils.host import HostPage, get_self_netloc
|
|
||||||
from ...utils.metrics import TetrisMetricsProWithPPSVS, get_metrics
|
|
||||||
from ...utils.render import render
|
|
||||||
from ...utils.render.schemas.base import Avatar, Ranking
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_info import Info as V1TemplateInfo
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_info import Radar, TetraLeague, TetraLeagueHistory, TetraLeagueHistoryData
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_info import User as V1TemplateUser
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_user_info_v2 import Badge, Blitz, Sprint, Statistic, TetraLeagueStatistic
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_user_info_v2 import Info as V2TemplateInfo
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_user_info_v2 import TetraLeague as V2TemplateTetraLeague
|
|
||||||
from ...utils.render.schemas.tetrio.tetrio_user_info_v2 import User as V2TemplateUser
|
|
||||||
from ...utils.screenshot import screenshot
|
|
||||||
from ...utils.typing import Me, Number
|
|
||||||
from ..constant import CANT_VERIFY_MESSAGE
|
|
||||||
from . import alc
|
|
||||||
from .api import Player, User, UserInfoSuccess
|
|
||||||
from .api.models import TETRIOHistoricalData
|
|
||||||
from .api.schemas.tetra_league import TetraLeagueSuccess
|
|
||||||
from .api.schemas.user_info import NeverPlayedLeague, NeverRatedLeague, RatedLeague
|
|
||||||
from .constant import GAME_TYPE, TR_MAX, TR_MIN
|
|
||||||
from .models import IORank, TETRIOUserConfig
|
|
||||||
from .typing import Template
|
|
||||||
|
|
||||||
UTC = timezone.utc
|
|
||||||
|
|
||||||
driver = get_driver()
|
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.query')
|
|
||||||
async def _( # noqa: PLR0913
|
|
||||||
user: NBUser,
|
|
||||||
event: Event,
|
|
||||||
matcher: Matcher,
|
|
||||||
target: At | Me,
|
|
||||||
event_session: EventSession,
|
|
||||||
template: Template | None = None,
|
|
||||||
):
|
|
||||||
async with trigger(
|
|
||||||
session_persist_id=await get_session_persist_id(event_session),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
command_type='query',
|
|
||||||
command_args=[f'--default-template {template}'] if template is not None else [],
|
|
||||||
):
|
|
||||||
async with get_session() as session:
|
|
||||||
bind = await query_bind_info(
|
|
||||||
session=session,
|
|
||||||
user=await get_user(
|
|
||||||
event_session.platform, target.target if isinstance(target, At) else event.get_user_id()
|
|
||||||
),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
)
|
|
||||||
if template is None:
|
|
||||||
template = await session.scalar(
|
|
||||||
select(TETRIOUserConfig.query_template).where(TETRIOUserConfig.id == user.id)
|
|
||||||
)
|
|
||||||
if bind is None:
|
|
||||||
await matcher.finish('未查询到绑定信息')
|
|
||||||
message = UniMessage(CANT_VERIFY_MESSAGE)
|
|
||||||
player = Player(user_id=bind.game_account, trust=True)
|
|
||||||
await (message + (await make_query_result(player, template or 'v1'))).finish()
|
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.query')
|
|
||||||
async def _(user: NBUser, account: Player, event_session: EventSession, template: Template | None = None):
|
|
||||||
async with trigger(
|
|
||||||
session_persist_id=await get_session_persist_id(event_session),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
command_type='query',
|
|
||||||
command_args=[f'--default-template {template}'] if template is not None else [],
|
|
||||||
):
|
|
||||||
async with get_session() as session:
|
|
||||||
if template is None:
|
|
||||||
template = await session.scalar(
|
|
||||||
select(TETRIOUserConfig.query_template).where(TETRIOUserConfig.id == user.id)
|
|
||||||
)
|
|
||||||
await (await make_query_result(account, template or 'v1')).finish()
|
|
||||||
|
|
||||||
|
|
||||||
def get_value_bounds(values: list[int | float]) -> tuple[int, int]:
|
|
||||||
value_max = 10 * ceil(max(values) / 10)
|
|
||||||
value_min = 10 * floor(min(values) / 10)
|
|
||||||
return value_max, value_min
|
|
||||||
|
|
||||||
|
|
||||||
def get_split(value_max: int, value_min: int) -> tuple[int, int]:
|
|
||||||
offset = 0
|
|
||||||
overflow = 0
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if (new_max_value := value_max + offset + overflow) > TR_MAX:
|
|
||||||
overflow -= 1
|
|
||||||
continue
|
|
||||||
if (new_min_value := value_min - offset + overflow) < TR_MIN:
|
|
||||||
overflow += 1
|
|
||||||
continue
|
|
||||||
if ((new_max_value - new_min_value) / 40).is_integer():
|
|
||||||
split_value = int((value_max + offset - (value_min - offset)) / 4)
|
|
||||||
break
|
|
||||||
offset += 1
|
|
||||||
return split_value, offset + overflow
|
|
||||||
|
|
||||||
|
|
||||||
def get_specified_point(
|
|
||||||
previous_point: TetraLeagueHistoryData,
|
|
||||||
behind_point: TetraLeagueHistoryData,
|
|
||||||
point_time: datetime,
|
|
||||||
) -> TetraLeagueHistoryData:
|
|
||||||
"""根据给出的 previous_point 和 behind_point, 推算 point_time 点处的数据
|
|
||||||
|
|
||||||
Args:
|
|
||||||
previous_point (Data): 前面的数据点
|
|
||||||
behind_point (Data): 后面的数据点
|
|
||||||
point_time (datetime): 要推算的点的位置
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Data: 要推算的点的数据
|
|
||||||
"""
|
|
||||||
# 求两个点的斜率
|
|
||||||
slope = (behind_point.tr - previous_point.tr) / (
|
|
||||||
datetime.timestamp(behind_point.record_at) - datetime.timestamp(previous_point.record_at)
|
|
||||||
)
|
|
||||||
return TetraLeagueHistoryData(
|
|
||||||
record_at=point_time,
|
|
||||||
tr=previous_point.tr + slope * (datetime.timestamp(point_time) - datetime.timestamp(previous_point.record_at)),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def query_historical_data(user: User, user_info: UserInfoSuccess) -> list[TetraLeagueHistoryData]:
|
|
||||||
today = datetime.now(ZoneInfo('Asia/Shanghai')).replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
forward = timedelta(days=9)
|
|
||||||
start_time = (today - forward).astimezone(UTC)
|
|
||||||
async with get_session() as session:
|
|
||||||
historical_data = (
|
|
||||||
await session.scalars(
|
|
||||||
select(TETRIOHistoricalData)
|
|
||||||
.where(TETRIOHistoricalData.update_time >= start_time)
|
|
||||||
.where(TETRIOHistoricalData.user_unique_identifier == user.unique_identifier)
|
|
||||||
.where(TETRIOHistoricalData.api_type == 'User Info')
|
|
||||||
)
|
|
||||||
).all()
|
|
||||||
if historical_data:
|
|
||||||
extra = (
|
|
||||||
await session.scalars(
|
|
||||||
select(TETRIOHistoricalData)
|
|
||||||
.where(TETRIOHistoricalData.user_unique_identifier == user.unique_identifier)
|
|
||||||
.where(TETRIOHistoricalData.api_type == 'User Info')
|
|
||||||
.order_by(TETRIOHistoricalData.id.desc())
|
|
||||||
.where(TETRIOHistoricalData.id < min([i.id for i in historical_data]))
|
|
||||||
.limit(1)
|
|
||||||
)
|
|
||||||
).one_or_none()
|
|
||||||
if extra is not None:
|
|
||||||
historical_data = list(historical_data)
|
|
||||||
historical_data.append(extra)
|
|
||||||
full_export_data = FullExport.get_data(user.unique_identifier)
|
|
||||||
if not historical_data and not full_export_data:
|
|
||||||
return [
|
|
||||||
TetraLeagueHistoryData(record_at=today - forward, tr=user_info.data.user.league.rating),
|
|
||||||
TetraLeagueHistoryData(record_at=today.replace(microsecond=1000), tr=user_info.data.user.league.rating),
|
|
||||||
]
|
|
||||||
histories = [
|
|
||||||
TetraLeagueHistoryData(
|
|
||||||
record_at=i.update_time.astimezone(ZoneInfo('Asia/Shanghai')),
|
|
||||||
tr=i.data.data.user.league.rating,
|
|
||||||
)
|
|
||||||
for i in historical_data
|
|
||||||
if isinstance(i.data, UserInfoSuccess) and isinstance(i.data.data.user.league, RatedLeague)
|
|
||||||
] + full_export_data
|
|
||||||
|
|
||||||
# 按照时间排序
|
|
||||||
histories = sorted(histories, key=lambda x: x.record_at)
|
|
||||||
for index, value in enumerate(histories):
|
|
||||||
# 在历史记录里找有没有今天0点后的数据, 并且至少要有两个数据点
|
|
||||||
if value.record_at > today and len(histories) >= 2: # noqa: PLR2004
|
|
||||||
histories = histories[:index] + [
|
|
||||||
get_specified_point(histories[index - 1], histories[index], today.replace(microsecond=1000))
|
|
||||||
]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
histories.append(
|
|
||||||
get_specified_point(
|
|
||||||
histories[-1],
|
|
||||||
TetraLeagueHistoryData(record_at=user_info.cache.cached_at, tr=user_info.data.user.league.rating),
|
|
||||||
today.replace(microsecond=1000),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if histories[0].record_at < (today - forward):
|
|
||||||
histories[0] = get_specified_point(
|
|
||||||
histories[0],
|
|
||||||
histories[1],
|
|
||||||
today - forward,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
histories.insert(0, TetraLeagueHistoryData(record_at=today - forward, tr=histories[0].tr))
|
|
||||||
return histories
|
|
||||||
|
|
||||||
|
|
||||||
L = TypeVar('L', NeverPlayedLeague, NeverRatedLeague, RatedLeague)
|
|
||||||
|
|
||||||
|
|
||||||
@overload
|
|
||||||
def get_league(user_info: UserInfoSuccess, league_type: type[L]) -> L: ...
|
|
||||||
@overload
|
|
||||||
def get_league(
|
|
||||||
user_info: UserInfoSuccess, league_type: None = None
|
|
||||||
) -> NeverPlayedLeague | NeverRatedLeague | RatedLeague: ...
|
|
||||||
def get_league(
|
|
||||||
user_info: UserInfoSuccess, league_type: type[L] | None = None
|
|
||||||
) -> L | NeverPlayedLeague | NeverRatedLeague | RatedLeague:
|
|
||||||
league = user_info.data.user.league
|
|
||||||
if league_type is None:
|
|
||||||
return league
|
|
||||||
if isinstance(league, league_type):
|
|
||||||
return league
|
|
||||||
raise FallbackError
|
|
||||||
|
|
||||||
|
|
||||||
async def make_query_image_v1(player: Player) -> bytes:
|
|
||||||
user, user_info, sprint, blitz = await gather(player.user, player.get_info(), player.sprint, player.blitz)
|
|
||||||
league = get_league(user_info, RatedLeague)
|
|
||||||
if league.vs is None:
|
|
||||||
raise FallbackError
|
|
||||||
histories = await query_historical_data(user, user_info)
|
|
||||||
value_max, value_min = get_value_bounds([i.tr for i in histories])
|
|
||||||
split_value, offset = get_split(value_max, value_min)
|
|
||||||
if sprint.record is not None:
|
|
||||||
duration = timedelta(milliseconds=sprint.record.endcontext.final_time).total_seconds()
|
|
||||||
sprint_value = f'{duration:.3f}s' if duration < 60 else f'{duration // 60:.0f}m {duration % 60:.3f}s' # noqa: PLR2004
|
|
||||||
else:
|
|
||||||
sprint_value = 'N/A'
|
|
||||||
blitz_value = f'{blitz.record.endcontext.score:,}' if blitz.record is not None else 'N/A'
|
|
||||||
netloc = get_self_netloc()
|
|
||||||
async with HostPage(
|
|
||||||
page=await render(
|
|
||||||
'v1/tetrio/info',
|
|
||||||
V1TemplateInfo(
|
|
||||||
user=V1TemplateUser(
|
|
||||||
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": user_info.data.user.avatar_revision})}'
|
|
||||||
if user_info.data.user.avatar_revision is not None and user_info.data.user.avatar_revision != 0
|
|
||||||
else Avatar(
|
|
||||||
type='identicon',
|
|
||||||
hash=md5(user_info.data.user.id.encode()).hexdigest(), # noqa: S324
|
|
||||||
),
|
|
||||||
name=user.name.upper(),
|
|
||||||
bio=user_info.data.user.bio,
|
|
||||||
),
|
|
||||||
ranking=Ranking(
|
|
||||||
rating=round(league.glicko, 2),
|
|
||||||
rd=round(league.rd, 2),
|
|
||||||
),
|
|
||||||
tetra_league=TetraLeague(
|
|
||||||
rank=league.rank,
|
|
||||||
tr=round(league.rating, 2),
|
|
||||||
global_rank=league.standing,
|
|
||||||
pps=league.pps,
|
|
||||||
lpm=round(lpm := (league.pps * 24), 2),
|
|
||||||
apm=league.apm,
|
|
||||||
apl=round(league.apm / lpm, 2),
|
|
||||||
vs=league.vs,
|
|
||||||
adpm=round(adpm := (league.vs * 0.6), 2),
|
|
||||||
adpl=round(adpm / lpm, 2),
|
|
||||||
),
|
|
||||||
tetra_league_history=TetraLeagueHistory(
|
|
||||||
data=histories,
|
|
||||||
split_interval=split_value,
|
|
||||||
min_tr=value_min,
|
|
||||||
max_tr=value_max,
|
|
||||||
offset=offset,
|
|
||||||
),
|
|
||||||
radar=Radar(
|
|
||||||
app=(app := (league.apm / (60 * league.pps))),
|
|
||||||
dsps=(dsps := ((league.vs / 100) - (league.apm / 60))),
|
|
||||||
dspp=(dspp := (dsps / league.pps)),
|
|
||||||
ci=150 * dspp - 125 * app + 50 * (league.vs / league.apm) - 25,
|
|
||||||
ge=2 * ((app * dsps) / league.pps),
|
|
||||||
),
|
|
||||||
sprint=sprint_value,
|
|
||||||
blitz=blitz_value,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
) as page_hash:
|
|
||||||
return await screenshot(f'http://{netloc}/host/{page_hash}.html')
|
|
||||||
|
|
||||||
|
|
||||||
N = TypeVar('N', int, float)
|
|
||||||
|
|
||||||
|
|
||||||
def handling_special_value(value: N) -> N | None:
|
|
||||||
return value if value != -1 else None
|
|
||||||
|
|
||||||
|
|
||||||
async def make_query_image_v2(player: Player) -> bytes:
|
|
||||||
user, user_info, sprint, blitz, zen = await gather(
|
|
||||||
player.user, player.get_info(), player.sprint, player.blitz, player.zen
|
|
||||||
)
|
|
||||||
league = get_league(user_info)
|
|
||||||
histories = await query_historical_data(user, user_info)
|
|
||||||
|
|
||||||
if sprint.record is not None:
|
|
||||||
duration = timedelta(milliseconds=sprint.record.endcontext.final_time).total_seconds()
|
|
||||||
sprint_value = f'{duration:.3f}s' if duration < 60 else f'{duration // 60:.0f}m {duration % 60:.3f}s' # noqa: PLR2004
|
|
||||||
else:
|
|
||||||
sprint_value = 'N/A'
|
|
||||||
|
|
||||||
play_time: str | None
|
|
||||||
if (game_time := handling_special_value(user_info.data.user.gametime)) is not None:
|
|
||||||
if game_time // 3600 > 0:
|
|
||||||
play_time = f'{game_time//3600:.0f}h {game_time % 3600 // 60:.0f}m {game_time % 60:.0f}s'
|
|
||||||
elif game_time // 60 > 0:
|
|
||||||
play_time = f'{game_time//60:.0f}m {game_time % 60:.0f}s'
|
|
||||||
else:
|
|
||||||
play_time = f'{game_time:.0f}s'
|
|
||||||
else:
|
|
||||||
play_time = game_time
|
|
||||||
netloc = get_self_netloc()
|
|
||||||
async with HostPage(
|
|
||||||
await render(
|
|
||||||
'v2/tetrio/user/info',
|
|
||||||
V2TemplateInfo(
|
|
||||||
user=V2TemplateUser(
|
|
||||||
id=user.ID,
|
|
||||||
name=user.name.upper(),
|
|
||||||
bio=user_info.data.user.bio,
|
|
||||||
banner=f'http://{netloc}/host/resource/tetrio/banners/{user.ID}?{urlencode({"revision": user_info.data.user.banner_revision})}'
|
|
||||||
if user_info.data.user.banner_revision is not None and user_info.data.user.banner_revision != 0
|
|
||||||
else None,
|
|
||||||
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": user_info.data.user.avatar_revision})}'
|
|
||||||
if user_info.data.user.avatar_revision is not None and user_info.data.user.avatar_revision != 0
|
|
||||||
else Avatar(
|
|
||||||
type='identicon',
|
|
||||||
hash=md5(user_info.data.user.id.encode()).hexdigest(), # noqa: S324
|
|
||||||
),
|
|
||||||
badges=[
|
|
||||||
Badge(
|
|
||||||
id=i.id,
|
|
||||||
description=i.label,
|
|
||||||
group=i.group,
|
|
||||||
receive_at=i.ts if isinstance(i.ts, datetime) else None,
|
|
||||||
)
|
|
||||||
for i in user_info.data.user.badges
|
|
||||||
],
|
|
||||||
country=user_info.data.user.country,
|
|
||||||
role=user_info.data.user.role,
|
|
||||||
xp=user_info.data.user.xp,
|
|
||||||
friend_count=user_info.data.user.friend_count,
|
|
||||||
supporter_tier=user_info.data.user.supporter_tier,
|
|
||||||
bad_standing=user_info.data.user.badstanding or False,
|
|
||||||
verified=user_info.data.user.verified,
|
|
||||||
playtime=play_time,
|
|
||||||
join_at=user_info.data.user.ts,
|
|
||||||
),
|
|
||||||
tetra_league=V2TemplateTetraLeague(
|
|
||||||
rank=league.rank,
|
|
||||||
highest_rank=league.bestrank,
|
|
||||||
tr=round(league.rating, 2),
|
|
||||||
glicko=round(league.glicko, 2),
|
|
||||||
rd=round(league.rd, 2),
|
|
||||||
global_rank=handling_special_value(league.standing),
|
|
||||||
country_rank=handling_special_value(league.standing_local),
|
|
||||||
pps=(
|
|
||||||
metrics := get_metrics(pps=league.pps, apm=league.apm, vs=league.vs)
|
|
||||||
if league.vs is not None
|
|
||||||
else get_metrics(pps=league.pps, apm=league.apm)
|
|
||||||
).pps,
|
|
||||||
apm=metrics.apm,
|
|
||||||
apl=metrics.apl,
|
|
||||||
vs=metrics.vs if isinstance(metrics, TetrisMetricsProWithPPSVS) else None,
|
|
||||||
adpl=metrics.adpl if isinstance(metrics, TetrisMetricsProWithPPSVS) else None,
|
|
||||||
statistic=TetraLeagueStatistic(
|
|
||||||
total=league.gamesplayed,
|
|
||||||
wins=league.gameswon,
|
|
||||||
),
|
|
||||||
decaying=league.decaying,
|
|
||||||
history=histories,
|
|
||||||
)
|
|
||||||
if isinstance(league, RatedLeague)
|
|
||||||
else None,
|
|
||||||
statistic=Statistic(
|
|
||||||
total=handling_special_value(user_info.data.user.gamesplayed),
|
|
||||||
wins=handling_special_value(user_info.data.user.gameswon),
|
|
||||||
),
|
|
||||||
sprint=Sprint(
|
|
||||||
time=sprint_value,
|
|
||||||
global_rank=sprint.rank,
|
|
||||||
play_at=sprint.record.ts,
|
|
||||||
)
|
|
||||||
if sprint.record is not None
|
|
||||||
else None,
|
|
||||||
blitz=Blitz(
|
|
||||||
score=blitz.record.endcontext.score,
|
|
||||||
global_rank=blitz.rank,
|
|
||||||
play_at=blitz.record.ts,
|
|
||||||
)
|
|
||||||
if blitz.record is not None
|
|
||||||
else None,
|
|
||||||
zen=zen,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) as page_hash:
|
|
||||||
return await screenshot(f'http://{netloc}/host/{page_hash}.html')
|
|
||||||
|
|
||||||
|
|
||||||
async def make_query_text(player: Player) -> UniMessage:
|
|
||||||
user, user_info, sprint, blitz = await gather(player.user, player.get_info(), player.sprint, player.blitz)
|
|
||||||
league = get_league(user_info)
|
|
||||||
|
|
||||||
user_name = user.name.upper()
|
|
||||||
|
|
||||||
message = ''
|
|
||||||
if isinstance(league, NeverPlayedLeague):
|
|
||||||
message += f'用户 {user_name} 没有排位统计数据'
|
|
||||||
else:
|
|
||||||
if isinstance(league, NeverRatedLeague):
|
|
||||||
message += f'用户 {user_name} 暂未完成定级赛, 最近十场的数据:'
|
|
||||||
else:
|
|
||||||
if league.rank == 'z':
|
|
||||||
message += f'用户 {user_name} 暂无段位, {round(league.rating,2)} TR'
|
|
||||||
else:
|
|
||||||
message += f'{league.rank.upper()} 段用户 {user_name} {round(league.rating,2)} TR (#{league.standing})'
|
|
||||||
message += f', 段位分 {round(league.glicko,2)}±{round(league.rd,2)}, 最近十场的数据:'
|
|
||||||
metrics = (
|
|
||||||
get_metrics(pps=league.pps, apm=league.apm, vs=league.vs)
|
|
||||||
if league.vs is not None
|
|
||||||
else get_metrics(pps=league.pps, apm=league.apm)
|
|
||||||
)
|
|
||||||
message += f"\nL'PM: {metrics.lpm} ( {metrics.pps} pps )"
|
|
||||||
message += f'\nAPM: {metrics.apm} ( x{metrics.apl} )'
|
|
||||||
if isinstance(metrics, TetrisMetricsProWithPPSVS):
|
|
||||||
message += f'\nADPM: {metrics.adpm} ( x{metrics.adpl} ) ( {metrics.vs}vs )'
|
|
||||||
if sprint.record is not None:
|
|
||||||
message += f'\n40L: {round(sprint.record.endcontext.final_time/1000,2)}s'
|
|
||||||
message += f' ( #{sprint.rank} )' if sprint.rank is not None else ''
|
|
||||||
if blitz.record is not None:
|
|
||||||
message += f'\nBlitz: {blitz.record.endcontext.score}'
|
|
||||||
message += f' ( #{blitz.rank} )' if blitz.rank is not None else ''
|
|
||||||
return UniMessage(message)
|
|
||||||
|
|
||||||
|
|
||||||
async def make_query_result(player: Player, template: Template) -> UniMessage:
|
|
||||||
try:
|
|
||||||
if template == 'v1':
|
|
||||||
return UniMessage.image(raw=await make_query_image_v1(player))
|
|
||||||
if template == 'v2':
|
|
||||||
return UniMessage.image(raw=await make_query_image_v2(player))
|
|
||||||
except FallbackError:
|
|
||||||
...
|
|
||||||
return await make_query_text(player)
|
|
||||||
|
|
||||||
|
|
||||||
class FullExport:
|
|
||||||
cache: ClassVar[defaultdict[str, set[tuple[datetime, Number]]]] = defaultdict(set)
|
|
||||||
latest_update: ClassVar[date | None] = None
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def init(cls) -> None:
|
|
||||||
async with get_session() as session:
|
|
||||||
full_exports = (await session.scalars(select(IORank).where(IORank.update_time >= cls.start_time()))).all()
|
|
||||||
await gather(
|
|
||||||
*[
|
|
||||||
cls._load(update_time, file_hash)
|
|
||||||
for file_hash, update_time in {
|
|
||||||
i.file_hash: i.update_time for i in full_exports if i.file_hash is not None
|
|
||||||
}.items()
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def update(cls) -> None:
|
|
||||||
if cls.latest_update == datetime.now(tz=ZoneInfo('Asia/Shanghai')).date():
|
|
||||||
return
|
|
||||||
start_time = cls.start_time()
|
|
||||||
for i in cls.cache:
|
|
||||||
cls.cache[i] = {j for j in cls.cache[i] if j[0] >= start_time}
|
|
||||||
latest_time = max(cls.cache)
|
|
||||||
async with get_session() as session:
|
|
||||||
full_exports = (await session.scalars(select(IORank).where(IORank.update_time > latest_time))).all()
|
|
||||||
await gather(
|
|
||||||
*[
|
|
||||||
cls._load(update_time, file_hash)
|
|
||||||
for file_hash, update_time in {
|
|
||||||
i.file_hash: i.update_time for i in full_exports if i.file_hash is not None
|
|
||||||
}.items()
|
|
||||||
]
|
|
||||||
)
|
|
||||||
cls.latest_update = datetime.now(tz=ZoneInfo('Asia/Shanghai')).date()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_data(cls, unique_identifier: str) -> list[TetraLeagueHistoryData]:
|
|
||||||
return [TetraLeagueHistoryData(record_at=i[0], tr=i[1]) for i in cls.cache[unique_identifier]]
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def start_time(cls) -> datetime:
|
|
||||||
return (
|
|
||||||
datetime.now(ZoneInfo('Asia/Shanghai')).replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
- timedelta(days=9)
|
|
||||||
).astimezone(UTC)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def _load(cls, update_time: datetime, file_hash: str) -> None:
|
|
||||||
try:
|
|
||||||
users = type_validate_json(TetraLeagueSuccess, await cls.decompress(file_hash)).data.users
|
|
||||||
except FileNotFoundError:
|
|
||||||
await cls.clear_invalid(file_hash)
|
|
||||||
return
|
|
||||||
update_time = update_time.astimezone(ZoneInfo('Asia/Shanghai'))
|
|
||||||
for i in users:
|
|
||||||
cls.cache[i.id].add((update_time, i.league.rating))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def decompress(cls, file_hash: str) -> bytes:
|
|
||||||
async with open(get_data_file('nonebot_plugin_tetris_stats', f'{file_hash}.json.zst'), mode='rb') as file:
|
|
||||||
return ZstdDecompressor().decompress(await file.read())
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def clear_invalid(cls, file_hash: str) -> None:
|
|
||||||
async with get_session() as session:
|
|
||||||
full_exports = (await session.scalars(select(IORank).where(IORank.file_hash == file_hash))).all()
|
|
||||||
for i in full_exports:
|
|
||||||
i.file_hash = None
|
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
@driver.on_startup
|
|
||||||
async def _():
|
|
||||||
await FullExport.init()
|
|
||||||
scheduler.add_job(FullExport.update, 'interval', hours=1)
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
from collections import defaultdict
|
|
||||||
from collections.abc import Callable
|
|
||||||
from datetime import datetime, timedelta, timezone
|
|
||||||
from hashlib import sha512
|
|
||||||
from math import floor
|
|
||||||
from statistics import mean
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from aiofiles import open
|
|
||||||
from nonebot import get_driver
|
|
||||||
from nonebot.compat import model_dump
|
|
||||||
from nonebot.utils import run_sync
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot_plugin_localstore import get_data_file
|
|
||||||
from nonebot_plugin_orm import get_session
|
|
||||||
from sqlalchemy import select
|
|
||||||
from zstandard import ZstdCompressor
|
|
||||||
|
|
||||||
from ....utils.exception import RequestError
|
|
||||||
from ....utils.retry import retry
|
|
||||||
from ..api.schemas.base import FailedModel
|
|
||||||
from ..api.schemas.tetra_league import ValidUser
|
|
||||||
from ..api.schemas.user import User
|
|
||||||
from ..api.tetra_league import full_export
|
|
||||||
from ..constant import RANK_PERCENTILE
|
|
||||||
from ..models import IORank
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from ..api.typing import Rank
|
|
||||||
|
|
||||||
UTC = timezone.utc
|
|
||||||
|
|
||||||
driver = get_driver()
|
|
||||||
|
|
||||||
|
|
||||||
@scheduler.scheduled_job('cron', hour='0,6,12,18', minute=0)
|
|
||||||
@retry(exception_type=RequestError, delay=timedelta(minutes=15))
|
|
||||||
async def get_tetra_league_data() -> None:
|
|
||||||
league, original = await full_export(with_original=True)
|
|
||||||
if isinstance(league, FailedModel):
|
|
||||||
msg = f'排行榜数据请求错误:\n{league.error}'
|
|
||||||
raise RequestError(msg)
|
|
||||||
|
|
||||||
def pps(user: ValidUser) -> float:
|
|
||||||
return user.league.pps
|
|
||||||
|
|
||||||
def apm(user: ValidUser) -> float:
|
|
||||||
return user.league.apm
|
|
||||||
|
|
||||||
def vs(user: ValidUser) -> float:
|
|
||||||
return user.league.vs
|
|
||||||
|
|
||||||
def _min(users: list[ValidUser], field: Callable[[ValidUser], float]) -> ValidUser:
|
|
||||||
return min(users, key=field)
|
|
||||||
|
|
||||||
def _max(users: list[ValidUser], field: Callable[[ValidUser], float]) -> ValidUser:
|
|
||||||
return max(users, key=field)
|
|
||||||
|
|
||||||
def build_extremes_data(
|
|
||||||
users: list[ValidUser],
|
|
||||||
field: Callable[[ValidUser], float],
|
|
||||||
sort: Callable[[list[ValidUser], Callable[[ValidUser], float]], ValidUser],
|
|
||||||
) -> tuple[dict[str, str], float]:
|
|
||||||
user = sort(users, field)
|
|
||||||
return model_dump(User(ID=user.id, name=user.username)), field(user)
|
|
||||||
|
|
||||||
data_hash: str | None = await run_sync((await run_sync(sha512)(original)).hexdigest)()
|
|
||||||
async with open(get_data_file('nonebot_plugin_tetris_stats', f'{data_hash}.json.zst'), mode='wb') as file:
|
|
||||||
await file.write(await run_sync(ZstdCompressor(level=12, threads=-1).compress)(original))
|
|
||||||
|
|
||||||
users = [i for i in league.data.users if isinstance(i, ValidUser)]
|
|
||||||
rank_to_users: defaultdict[Rank, list[ValidUser]] = defaultdict(list)
|
|
||||||
for i in users:
|
|
||||||
rank_to_users[i.league.rank].append(i)
|
|
||||||
rank_info: list[IORank] = []
|
|
||||||
for rank, percentile in RANK_PERCENTILE.items():
|
|
||||||
offset = floor((percentile / 100) * len(users)) - 1
|
|
||||||
tr_line = users[offset].league.rating
|
|
||||||
rank_users = rank_to_users[rank]
|
|
||||||
rank_info.append(
|
|
||||||
IORank(
|
|
||||||
rank=rank,
|
|
||||||
tr_line=tr_line,
|
|
||||||
player_count=len(rank_users),
|
|
||||||
low_pps=(build_extremes_data(rank_users, pps, _min)),
|
|
||||||
low_apm=(build_extremes_data(rank_users, apm, _min)),
|
|
||||||
low_vs=(build_extremes_data(rank_users, vs, _min)),
|
|
||||||
avg_pps=mean({i.league.pps for i in rank_users}),
|
|
||||||
avg_apm=mean({i.league.apm for i in rank_users}),
|
|
||||||
avg_vs=mean({i.league.vs for i in rank_users}),
|
|
||||||
high_pps=(build_extremes_data(rank_users, pps, _max)),
|
|
||||||
high_apm=(build_extremes_data(rank_users, apm, _max)),
|
|
||||||
high_vs=(build_extremes_data(rank_users, vs, _max)),
|
|
||||||
update_time=league.cache.cached_at,
|
|
||||||
file_hash=data_hash,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
async with get_session() as session:
|
|
||||||
session.add_all(rank_info)
|
|
||||||
await session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
@driver.on_startup
|
|
||||||
async def _() -> None:
|
|
||||||
async with get_session() as session:
|
|
||||||
latest_time = await session.scalar(select(IORank.update_time).order_by(IORank.id.desc()).limit(1))
|
|
||||||
if latest_time is None or datetime.now(tz=UTC) - latest_time.replace(tzinfo=UTC) > timedelta(hours=6):
|
|
||||||
await get_tetra_league_data()
|
|
||||||
|
|
||||||
|
|
||||||
from . import all, detail # noqa: E402
|
|
||||||
|
|
||||||
__all__ = ['all', 'detail']
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
from nonebot_plugin_alconna import UniMessage
|
|
||||||
from nonebot_plugin_orm import get_session
|
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_session_orm import get_session_persist_id # type: ignore[import-untyped]
|
|
||||||
from sqlalchemy import func, select
|
|
||||||
|
|
||||||
from ....db import trigger
|
|
||||||
from ....utils.host import HostPage, get_self_netloc
|
|
||||||
from ....utils.metrics import get_metrics
|
|
||||||
from ....utils.render import render
|
|
||||||
from ....utils.render.schemas.tetrio.tetrio_rank import AverageData, Data, ItemData
|
|
||||||
from ....utils.screenshot import screenshot
|
|
||||||
from .. import alc
|
|
||||||
from ..constant import GAME_TYPE
|
|
||||||
from ..models import IORank
|
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.rank.all')
|
|
||||||
async def _(event_session: EventSession):
|
|
||||||
async with trigger(
|
|
||||||
session_persist_id=await get_session_persist_id(event_session),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
command_type='rank',
|
|
||||||
command_args=['--all'],
|
|
||||||
):
|
|
||||||
async with get_session() as session:
|
|
||||||
latest_update_time = (
|
|
||||||
await session.scalars(select(IORank.update_time).order_by(IORank.id.desc()).limit(1))
|
|
||||||
).one()
|
|
||||||
compare_time = (
|
|
||||||
await session.scalars(
|
|
||||||
select(IORank.update_time)
|
|
||||||
.order_by(
|
|
||||||
func.abs(
|
|
||||||
func.julianday(IORank.update_time)
|
|
||||||
- func.julianday(latest_update_time - timedelta(hours=24))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1)
|
|
||||||
)
|
|
||||||
).one()
|
|
||||||
latest_data = (
|
|
||||||
await session.scalars(
|
|
||||||
select(IORank).where(IORank.update_time == latest_update_time).order_by(IORank.tr_line.desc())
|
|
||||||
)
|
|
||||||
).all()
|
|
||||||
compare_data = (
|
|
||||||
await session.scalars(
|
|
||||||
select(IORank).where(IORank.update_time == compare_time).order_by(IORank.tr_line.desc())
|
|
||||||
)
|
|
||||||
).all()
|
|
||||||
async with HostPage(
|
|
||||||
await render(
|
|
||||||
'v2/tetrio/rank',
|
|
||||||
Data(
|
|
||||||
items={
|
|
||||||
i[0].rank: ItemData(
|
|
||||||
require_tr=round(i[0].tr_line, 2),
|
|
||||||
trending=round(i[0].tr_line - i[1].tr_line, 2),
|
|
||||||
average_data=AverageData(
|
|
||||||
pps=(metrics := get_metrics(pps=i[0].avg_pps, apm=i[0].avg_apm, vs=i[0].avg_vs)).pps,
|
|
||||||
apm=metrics.apm,
|
|
||||||
apl=metrics.apl,
|
|
||||||
vs=metrics.vs,
|
|
||||||
adpl=metrics.adpl,
|
|
||||||
),
|
|
||||||
players=i[0].player_count,
|
|
||||||
)
|
|
||||||
for i in zip(latest_data, compare_data, strict=True)
|
|
||||||
},
|
|
||||||
updated_at=latest_update_time,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
) as page_hash:
|
|
||||||
await screenshot(f'http://{get_self_netloc()}/host/{page_hash}.html')
|
|
||||||
await UniMessage.image(raw=await screenshot(f'http://{get_self_netloc()}/host/{page_hash}.html')).finish()
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
from datetime import datetime, timedelta, timezone
|
|
||||||
from zoneinfo import ZoneInfo
|
|
||||||
|
|
||||||
from nonebot import get_driver
|
|
||||||
from nonebot_plugin_alconna import UniMessage
|
|
||||||
from nonebot_plugin_orm import get_session
|
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
|
||||||
from nonebot_plugin_session_orm import get_session_persist_id # type: ignore[import-untyped]
|
|
||||||
from sqlalchemy import func, select
|
|
||||||
|
|
||||||
from ....db import trigger
|
|
||||||
from ....utils.host import HostPage, get_self_netloc
|
|
||||||
from ....utils.metrics import get_metrics
|
|
||||||
from ....utils.render import render
|
|
||||||
from ....utils.render.schemas.tetrio.tetrio_rank_detail import Data, SpecialData
|
|
||||||
from ....utils.screenshot import screenshot
|
|
||||||
from .. import alc
|
|
||||||
from ..api.typing import ValidRank
|
|
||||||
from ..constant import GAME_TYPE
|
|
||||||
from ..models import IORank
|
|
||||||
|
|
||||||
UTC = timezone.utc
|
|
||||||
|
|
||||||
driver = get_driver()
|
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.rank')
|
|
||||||
async def _(rank: ValidRank, event_session: EventSession):
|
|
||||||
async with trigger(
|
|
||||||
session_persist_id=await get_session_persist_id(event_session),
|
|
||||||
game_platform=GAME_TYPE,
|
|
||||||
command_type='rank',
|
|
||||||
command_args=[f'--detail {rank}'],
|
|
||||||
):
|
|
||||||
async with get_session() as session:
|
|
||||||
latest_data = (
|
|
||||||
await session.scalars(select(IORank).where(IORank.rank == rank).order_by(IORank.id.desc()).limit(1))
|
|
||||||
).one()
|
|
||||||
compare_data = (
|
|
||||||
await session.scalars(
|
|
||||||
select(IORank)
|
|
||||||
.where(IORank.rank == rank)
|
|
||||||
.order_by(
|
|
||||||
func.abs(
|
|
||||||
func.julianday(IORank.update_time)
|
|
||||||
- func.julianday(latest_data.update_time - timedelta(hours=24))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1)
|
|
||||||
)
|
|
||||||
).one()
|
|
||||||
await UniMessage.image(raw=await make_image(latest_data, compare_data)).finish()
|
|
||||||
|
|
||||||
|
|
||||||
async def make_image(latest_data: IORank, compare_data: IORank) -> bytes:
|
|
||||||
avg = get_metrics(pps=latest_data.avg_pps, apm=latest_data.avg_apm, vs=latest_data.avg_vs)
|
|
||||||
low_pps = get_metrics(pps=latest_data.low_pps[1])
|
|
||||||
low_vs = get_metrics(vs=latest_data.low_vs[1])
|
|
||||||
max_pps = get_metrics(pps=latest_data.high_pps[1])
|
|
||||||
max_vs = get_metrics(vs=latest_data.high_vs[1])
|
|
||||||
async with HostPage(
|
|
||||||
await render(
|
|
||||||
'v2/tetrio/rank/detail',
|
|
||||||
Data(
|
|
||||||
name=latest_data.rank,
|
|
||||||
trending=round(latest_data.tr_line - compare_data.tr_line, 2),
|
|
||||||
require_tr=round(latest_data.tr_line, 2),
|
|
||||||
players=latest_data.player_count,
|
|
||||||
minimum_data=SpecialData(
|
|
||||||
apm=latest_data.low_apm[1],
|
|
||||||
pps=low_pps.pps,
|
|
||||||
lpm=low_pps.lpm,
|
|
||||||
vs=low_vs.vs,
|
|
||||||
adpm=low_vs.adpm,
|
|
||||||
apm_holder=latest_data.low_apm[0]['name'].upper(),
|
|
||||||
pps_holder=latest_data.low_pps[0]['name'].upper(),
|
|
||||||
vs_holder=latest_data.low_vs[0]['name'].upper(),
|
|
||||||
),
|
|
||||||
average_data=SpecialData(
|
|
||||||
apm=avg.apm,
|
|
||||||
pps=avg.pps,
|
|
||||||
lpm=avg.lpm,
|
|
||||||
vs=avg.vs,
|
|
||||||
adpm=avg.adpm,
|
|
||||||
apl=avg.apl,
|
|
||||||
adpl=avg.adpl,
|
|
||||||
),
|
|
||||||
maximum_data=SpecialData(
|
|
||||||
apm=latest_data.high_apm[1],
|
|
||||||
pps=max_pps.pps,
|
|
||||||
lpm=max_pps.lpm,
|
|
||||||
vs=max_vs.vs,
|
|
||||||
adpm=max_vs.adpm,
|
|
||||||
apm_holder=latest_data.high_apm[0]['name'].upper(),
|
|
||||||
pps_holder=latest_data.high_pps[0]['name'].upper(),
|
|
||||||
vs_holder=latest_data.high_vs[0]['name'].upper(),
|
|
||||||
),
|
|
||||||
updated_at=latest_data.update_time.replace(tzinfo=UTC).astimezone(ZoneInfo('Asia/Shanghai')),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
) as page_hash:
|
|
||||||
return await screenshot(f'http://{get_self_netloc()}/host/{page_hash}.html')
|
|
||||||
|
|
||||||
|
|
||||||
async def make_text(latest_data: IORank, compare_data: IORank) -> str:
|
|
||||||
message = ''
|
|
||||||
if (datetime.now(UTC) - latest_data.update_time.replace(tzinfo=UTC)) > timedelta(hours=7):
|
|
||||||
message += 'Warning: 数据超过7小时未更新, 请联系Bot主人查看后台\n'
|
|
||||||
message += f'{latest_data.rank.upper()} 段 分数线 {latest_data.tr_line:.2f} TR, {latest_data.player_count} 名玩家\n'
|
|
||||||
if compare_data.id != latest_data.id:
|
|
||||||
message += f'对比 {(latest_data.update_time-compare_data.update_time).total_seconds()/3600:.2f} 小时前趋势: {f"↑{difference:.2f}" if (difference:=latest_data.tr_line-compare_data.tr_line) > 0 else f"↓{-difference:.2f}" if difference < 0 else "→"}'
|
|
||||||
else:
|
|
||||||
message += '暂无对比数据'
|
|
||||||
avg = get_metrics(pps=latest_data.avg_pps, apm=latest_data.avg_apm, vs=latest_data.avg_vs)
|
|
||||||
low_pps = get_metrics(pps=latest_data.low_pps[1])
|
|
||||||
low_vs = get_metrics(vs=latest_data.low_vs[1])
|
|
||||||
max_pps = get_metrics(pps=latest_data.high_pps[1])
|
|
||||||
max_vs = get_metrics(vs=latest_data.high_vs[1])
|
|
||||||
message += (
|
|
||||||
'\n'
|
|
||||||
'平均数据:\n'
|
|
||||||
f"L'PM: {avg.lpm} ( {avg.pps} pps )\n"
|
|
||||||
f'APM: {avg.apm} ( x{avg.apl} )\n'
|
|
||||||
f'ADPM: {avg.adpm} ( x{avg.adpl} ) ( {avg.vs}vs )\n'
|
|
||||||
'\n'
|
|
||||||
'最低数据:\n'
|
|
||||||
f"L'PM: {low_pps.lpm} ( {low_pps.pps} pps ) By: {latest_data.low_pps[0]['name'].upper()}\n"
|
|
||||||
f'APM: {latest_data.low_apm[1]} By: {latest_data.low_apm[0]["name"].upper()}\n'
|
|
||||||
f'ADPM: {low_vs.adpm} ( {low_vs.vs}vs ) By: {latest_data.low_vs[0]["name"].upper()}\n'
|
|
||||||
'\n'
|
|
||||||
'最高数据:\n'
|
|
||||||
f"L'PM: {max_pps.lpm} ( {max_pps.pps} pps ) By: {latest_data.high_pps[0]['name'].upper()}\n"
|
|
||||||
f'APM: {latest_data.high_apm[1]} By: {latest_data.high_apm[0]["name"].upper()}\n'
|
|
||||||
f'ADPM: {max_vs.adpm} ( {max_vs.vs}vs ) By: {latest_data.high_vs[0]["name"].upper()}\n'
|
|
||||||
'\n'
|
|
||||||
f'数据更新时间: {latest_data.update_time.replace(tzinfo=UTC).astimezone(ZoneInfo("Asia/Shanghai")).strftime("%Y-%m-%d %H:%M:%S")}'
|
|
||||||
)
|
|
||||||
return message
|
|
||||||
@@ -68,46 +68,48 @@ async def _(account: Player, event_session: EventSession):
|
|||||||
|
|
||||||
|
|
||||||
async def make_blitz_image(player: Player) -> bytes:
|
async def make_blitz_image(player: Player) -> bytes:
|
||||||
user, user_info, blitz = await gather(player.user, player.get_info(), player.blitz)
|
user, blitz = await gather(player.user, player.blitz)
|
||||||
if blitz.record is None:
|
if blitz.data.record is None:
|
||||||
msg = f'未找到用户 {user.name.upper()} 的 Blitz 记录'
|
msg = f'未找到用户 {user.name.upper()} 的 Blitz 记录'
|
||||||
raise RecordNotFoundError(msg)
|
raise RecordNotFoundError(msg)
|
||||||
endcontext = blitz.record.endcontext
|
stats = blitz.data.record.results.stats
|
||||||
clears = endcontext.clears
|
clears = stats.clears
|
||||||
duration = timedelta(milliseconds=endcontext.final_time).total_seconds()
|
duration = timedelta(milliseconds=stats.finaltime).total_seconds()
|
||||||
metrics = get_metrics(pps=endcontext.piecesplaced / duration)
|
metrics = get_metrics(pps=stats.piecesplaced / duration)
|
||||||
netloc = get_self_netloc()
|
netloc = get_self_netloc()
|
||||||
async with HostPage(
|
async with HostPage(
|
||||||
page=await render(
|
page=await render(
|
||||||
'v2/tetrio/record/blitz',
|
'v2/tetrio/record/blitz',
|
||||||
Record(
|
Record(
|
||||||
|
type='personal_best',
|
||||||
user=User(
|
user=User(
|
||||||
id=user.ID,
|
id=user.ID,
|
||||||
name=user.name.upper(),
|
name=user.name.upper(),
|
||||||
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": user_info.data.user.avatar_revision})}'
|
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": avatar_revision})}'
|
||||||
if user_info.data.user.avatar_revision is not None and user_info.data.user.avatar_revision != 0
|
if (avatar_revision := (await player.avatar_revision)) is not None and avatar_revision != 0
|
||||||
else Avatar(
|
else Avatar(
|
||||||
type='identicon',
|
type='identicon',
|
||||||
hash=md5(user.ID.encode()).hexdigest(), # noqa: S324
|
hash=md5(user.ID.encode()).hexdigest(), # noqa: S324
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
replay_id=blitz.record.replayid,
|
replay_id=blitz.data.record.replayid,
|
||||||
rank=blitz.rank,
|
rank=blitz.data.rank,
|
||||||
|
personal_rank=1,
|
||||||
statistic=Statistic(
|
statistic=Statistic(
|
||||||
keys=endcontext.inputs,
|
keys=stats.inputs,
|
||||||
kpp=round(endcontext.inputs / endcontext.piecesplaced, 2),
|
kpp=round(stats.inputs / stats.piecesplaced, 2),
|
||||||
kps=round(endcontext.inputs / duration, 2),
|
kps=round(stats.inputs / duration, 2),
|
||||||
max=Max(
|
max=Max(
|
||||||
combo=max((0, endcontext.topcombo - 1)),
|
combo=max((0, stats.topcombo - 1)),
|
||||||
btb=max((0, endcontext.topbtb - 1)),
|
btb=max((0, stats.topbtb - 1)),
|
||||||
),
|
),
|
||||||
pieces=endcontext.piecesplaced,
|
pieces=stats.piecesplaced,
|
||||||
pps=metrics.pps,
|
pps=metrics.pps,
|
||||||
lines=endcontext.lines,
|
lines=stats.lines,
|
||||||
lpm=metrics.lpm,
|
lpm=metrics.lpm,
|
||||||
holds=endcontext.holds,
|
holds=stats.holds,
|
||||||
score=endcontext.score,
|
score=stats.score,
|
||||||
spp=round(endcontext.score / endcontext.piecesplaced, 2),
|
spp=round(stats.score / stats.piecesplaced, 2),
|
||||||
single=clears.singles,
|
single=clears.singles,
|
||||||
double=clears.doubles,
|
double=clears.doubles,
|
||||||
triple=clears.triples,
|
triple=clears.triples,
|
||||||
@@ -125,12 +127,12 @@ async def make_blitz_image(player: Player) -> bytes:
|
|||||||
),
|
),
|
||||||
all_clear=clears.allclear,
|
all_clear=clears.allclear,
|
||||||
finesse=Finesse(
|
finesse=Finesse(
|
||||||
faults=endcontext.finesse.faults,
|
faults=stats.finesse.faults,
|
||||||
accuracy=round(endcontext.finesse.perfectpieces / endcontext.piecesplaced * 100, 2),
|
accuracy=round(stats.finesse.perfectpieces / stats.piecesplaced * 100, 2),
|
||||||
),
|
),
|
||||||
level=endcontext.level,
|
level=stats.level,
|
||||||
),
|
),
|
||||||
play_at=blitz.record.ts,
|
play_at=blitz.data.record.ts,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
) as page_hash:
|
) as page_hash:
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ from ....utils.host import HostPage, get_self_netloc
|
|||||||
from ....utils.metrics import get_metrics
|
from ....utils.metrics import get_metrics
|
||||||
from ....utils.render import render
|
from ....utils.render import render
|
||||||
from ....utils.render.schemas.base import Avatar
|
from ....utils.render.schemas.base import Avatar
|
||||||
from ....utils.render.schemas.tetrio.tetrio_record_base import Finesse, Max, Mini, Tspins, User
|
from ....utils.render.schemas.tetrio.tetrio_record_base import Finesse, Max, Mini, Statistic, Tspins, User
|
||||||
from ....utils.render.schemas.tetrio.tetrio_record_sprint import Record, Statistic
|
from ....utils.render.schemas.tetrio.tetrio_record_sprint import Record
|
||||||
from ....utils.screenshot import screenshot
|
from ....utils.screenshot import screenshot
|
||||||
from ....utils.typing import Me
|
from ....utils.typing import Me
|
||||||
from ...constant import CANT_VERIFY_MESSAGE
|
from ...constant import CANT_VERIFY_MESSAGE
|
||||||
@@ -68,47 +68,49 @@ async def _(account: Player, event_session: EventSession):
|
|||||||
|
|
||||||
|
|
||||||
async def make_sprint_image(player: Player) -> bytes:
|
async def make_sprint_image(player: Player) -> bytes:
|
||||||
user, user_info, sprint = await gather(player.user, player.get_info(), player.sprint)
|
user, sprint = await gather(player.user, player.sprint)
|
||||||
if sprint.record is None:
|
if sprint.data.record is None:
|
||||||
msg = f'未找到用户 {user.name.upper()} 的 40L 记录'
|
msg = f'未找到用户 {user.name.upper()} 的 40L 记录'
|
||||||
raise RecordNotFoundError(msg)
|
raise RecordNotFoundError(msg)
|
||||||
endcontext = sprint.record.endcontext
|
stats = sprint.data.record.results.stats
|
||||||
clears = endcontext.clears
|
clears = stats.clears
|
||||||
duration = timedelta(milliseconds=endcontext.final_time).total_seconds()
|
duration = timedelta(milliseconds=stats.finaltime).total_seconds()
|
||||||
sprint_value = f'{duration:.3f}s' if duration < 60 else f'{duration // 60:.0f}m {duration % 60:.3f}s' # noqa: PLR2004
|
sprint_value = f'{duration:.3f}s' if duration < 60 else f'{duration // 60:.0f}m {duration % 60:.3f}s' # noqa: PLR2004
|
||||||
metrics = get_metrics(pps=endcontext.piecesplaced / duration)
|
metrics = get_metrics(pps=stats.piecesplaced / duration)
|
||||||
netloc = get_self_netloc()
|
netloc = get_self_netloc()
|
||||||
async with HostPage(
|
async with HostPage(
|
||||||
page=await render(
|
page=await render(
|
||||||
'v2/tetrio/record/40l',
|
'v2/tetrio/record/40l',
|
||||||
Record(
|
Record(
|
||||||
|
type='personal_best',
|
||||||
user=User(
|
user=User(
|
||||||
id=user.ID,
|
id=user.ID,
|
||||||
name=user.name.upper(),
|
name=user.name.upper(),
|
||||||
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": user_info.data.user.avatar_revision})}'
|
avatar=f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}?{urlencode({"revision": avatar_revision})}'
|
||||||
if user_info.data.user.avatar_revision is not None and user_info.data.user.avatar_revision != 0
|
if (avatar_revision := (await player.avatar_revision)) is not None and avatar_revision != 0
|
||||||
else Avatar(
|
else Avatar(
|
||||||
type='identicon',
|
type='identicon',
|
||||||
hash=md5(user.ID.encode()).hexdigest(), # noqa: S324
|
hash=md5(user.ID.encode()).hexdigest(), # noqa: S324
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
time=sprint_value,
|
time=sprint_value,
|
||||||
replay_id=sprint.record.replayid,
|
replay_id=sprint.data.record.replayid,
|
||||||
rank=sprint.rank,
|
rank=sprint.data.rank,
|
||||||
|
personal_rank=1,
|
||||||
statistic=Statistic(
|
statistic=Statistic(
|
||||||
keys=endcontext.inputs,
|
keys=stats.inputs,
|
||||||
kpp=round(endcontext.inputs / endcontext.piecesplaced, 2),
|
kpp=round(stats.inputs / stats.piecesplaced, 2),
|
||||||
kps=round(endcontext.inputs / duration, 2),
|
kps=round(stats.inputs / duration, 2),
|
||||||
max=Max(
|
max=Max(
|
||||||
combo=max((0, endcontext.topcombo - 1)),
|
combo=max((0, stats.topcombo - 1)),
|
||||||
btb=max((0, endcontext.topbtb - 1)),
|
btb=max((0, stats.topbtb - 1)),
|
||||||
),
|
),
|
||||||
pieces=endcontext.piecesplaced,
|
pieces=stats.piecesplaced,
|
||||||
pps=metrics.pps,
|
pps=metrics.pps,
|
||||||
lines=endcontext.lines,
|
lines=stats.lines,
|
||||||
lpm=metrics.lpm,
|
lpm=metrics.lpm,
|
||||||
holds=endcontext.holds,
|
holds=stats.holds,
|
||||||
score=endcontext.score,
|
score=stats.score,
|
||||||
single=clears.singles,
|
single=clears.singles,
|
||||||
double=clears.doubles,
|
double=clears.doubles,
|
||||||
triple=clears.triples,
|
triple=clears.triples,
|
||||||
@@ -126,11 +128,11 @@ async def make_sprint_image(player: Player) -> bytes:
|
|||||||
),
|
),
|
||||||
all_clear=clears.allclear,
|
all_clear=clears.allclear,
|
||||||
finesse=Finesse(
|
finesse=Finesse(
|
||||||
faults=endcontext.finesse.faults,
|
faults=stats.finesse.faults,
|
||||||
accuracy=round(endcontext.finesse.perfectpieces / endcontext.piecesplaced * 100, 2),
|
accuracy=round(stats.finesse.perfectpieces / stats.piecesplaced * 100, 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
play_at=sprint.record.ts,
|
play_at=sprint.data.record.ts,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
) as page_hash:
|
) as page_hash:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from nonebot.log import logger
|
|||||||
from ..config.config import CACHE_PATH
|
from ..config.config import CACHE_PATH
|
||||||
from .image import img_to_png
|
from .image import img_to_png
|
||||||
from .request import Request
|
from .request import Request
|
||||||
from .templates import templates_dir
|
from .templates import TEMPLATES_DIR
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from pydantic import IPvAnyAddress
|
from pydantic import IPvAnyAddress
|
||||||
@@ -48,7 +48,7 @@ class HostPage:
|
|||||||
def _():
|
def _():
|
||||||
app.mount(
|
app.mount(
|
||||||
'/host/assets',
|
'/host/assets',
|
||||||
StaticFiles(directory=templates_dir / 'assets'),
|
StaticFiles(directory=TEMPLATES_DIR / 'assets'),
|
||||||
name='assets',
|
name='assets',
|
||||||
)
|
)
|
||||||
logger.success('assets mounted')
|
logger.success('assets mounted')
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ from typing import Literal, overload
|
|||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
from nonebot.compat import PYDANTIC_V2
|
from nonebot.compat import PYDANTIC_V2
|
||||||
|
|
||||||
from ..templates import templates_dir
|
from ..templates import TEMPLATES_DIR
|
||||||
from .schemas.bind import Bind
|
from .schemas.bind import Bind
|
||||||
from .schemas.tetrio.tetrio_info import Info as TETRIOInfo
|
from .schemas.tetrio.tetrio_info import Info as TETRIOInfo
|
||||||
from .schemas.tetrio.tetrio_rank import Data as TETRIORankData
|
|
||||||
from .schemas.tetrio.tetrio_rank_detail import Data as TETRIORankDetailData
|
from .schemas.tetrio.tetrio_rank_detail import Data as TETRIORankDetailData
|
||||||
|
from .schemas.tetrio.tetrio_rank_v1 import Data as TETRIORankDataV1
|
||||||
|
from .schemas.tetrio.tetrio_rank_v2 import Data as TETRIORankDataV2
|
||||||
from .schemas.tetrio.tetrio_record_blitz import Record as TETRIORecordBlitz
|
from .schemas.tetrio.tetrio_record_blitz import Record as TETRIORecordBlitz
|
||||||
from .schemas.tetrio.tetrio_record_sprint import Record as TETRIORecordSprint
|
from .schemas.tetrio.tetrio_record_sprint import Record as TETRIORecordSprint
|
||||||
from .schemas.tetrio.tetrio_user_info_v2 import Info as TETRIOUserInfoV2
|
from .schemas.tetrio.tetrio_user_info_v2 import Info as TETRIOUserInfoV2
|
||||||
@@ -16,7 +17,7 @@ from .schemas.top_info import Info as TOPInfo
|
|||||||
from .schemas.tos_info import Info as TOSInfo
|
from .schemas.tos_info import Info as TOSInfo
|
||||||
|
|
||||||
env = Environment(
|
env = Environment(
|
||||||
loader=FileSystemLoader(templates_dir), autoescape=True, trim_blocks=True, lstrip_blocks=True, enable_async=True
|
loader=FileSystemLoader(TEMPLATES_DIR), autoescape=True, trim_blocks=True, lstrip_blocks=True, enable_async=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ async def render(render_type: Literal['v1/binding'], data: Bind) -> str: ...
|
|||||||
@overload
|
@overload
|
||||||
async def render(render_type: Literal['v1/tetrio/info'], data: TETRIOInfo) -> str: ...
|
async def render(render_type: Literal['v1/tetrio/info'], data: TETRIOInfo) -> str: ...
|
||||||
@overload
|
@overload
|
||||||
|
async def render(render_type: Literal['v1/tetrio/rank'], data: TETRIORankDataV1) -> str: ...
|
||||||
|
@overload
|
||||||
async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ...
|
async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ...
|
||||||
@overload
|
@overload
|
||||||
async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ...
|
async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ...
|
||||||
@@ -37,7 +40,7 @@ async def render(render_type: Literal['v2/tetrio/record/40l'], data: TETRIORecor
|
|||||||
@overload
|
@overload
|
||||||
async def render(render_type: Literal['v2/tetrio/record/blitz'], data: TETRIORecordBlitz) -> str: ...
|
async def render(render_type: Literal['v2/tetrio/record/blitz'], data: TETRIORecordBlitz) -> str: ...
|
||||||
@overload
|
@overload
|
||||||
async def render(render_type: Literal['v2/tetrio/rank'], data: TETRIORankData) -> str: ...
|
async def render(render_type: Literal['v2/tetrio/rank'], data: TETRIORankDataV2) -> str: ...
|
||||||
@overload
|
@overload
|
||||||
async def render(render_type: Literal['v2/tetrio/rank/detail'], data: TETRIORankDetailData) -> str: ...
|
async def render(render_type: Literal['v2/tetrio/rank/detail'], data: TETRIORankDetailData) -> str: ...
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ async def render(
|
|||||||
render_type: Literal[
|
render_type: Literal[
|
||||||
'v1/binding',
|
'v1/binding',
|
||||||
'v1/tetrio/info',
|
'v1/tetrio/info',
|
||||||
|
'v1/tetrio/rank',
|
||||||
'v1/top/info',
|
'v1/top/info',
|
||||||
'v1/tos/info',
|
'v1/tos/info',
|
||||||
'v2/tetrio/user/info',
|
'v2/tetrio/user/info',
|
||||||
@@ -57,13 +61,14 @@ async def render(
|
|||||||
],
|
],
|
||||||
data: Bind
|
data: Bind
|
||||||
| TETRIOInfo
|
| TETRIOInfo
|
||||||
|
| TETRIORankDataV1
|
||||||
| TOPInfo
|
| TOPInfo
|
||||||
| TOSInfo
|
| TOSInfo
|
||||||
| TETRIOUserInfoV2
|
| TETRIOUserInfoV2
|
||||||
| TETRIOUserListV2
|
| TETRIOUserListV2
|
||||||
| TETRIORecordSprint
|
| TETRIORecordSprint
|
||||||
| TETRIORecordBlitz
|
| TETRIORecordBlitz
|
||||||
| TETRIORankData
|
| TETRIORankDataV2
|
||||||
| TETRIORankDetailData,
|
| TETRIORankDetailData,
|
||||||
) -> str:
|
) -> str:
|
||||||
if PYDANTIC_V2:
|
if PYDANTIC_V2:
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from .....games.tetrio.api.typing import ValidRank
|
||||||
|
|
||||||
|
|
||||||
|
class ItemData(BaseModel):
|
||||||
|
trending: float
|
||||||
|
require_tr: float
|
||||||
|
players: int
|
||||||
|
|
||||||
|
|
||||||
|
class Data(BaseModel):
|
||||||
|
items: dict[ValidRank, ItemData]
|
||||||
|
updated_at: datetime
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ..base import People
|
from ..base import People
|
||||||
@@ -32,7 +35,7 @@ class Finesse(BaseModel):
|
|||||||
accuracy: float
|
accuracy: float
|
||||||
|
|
||||||
|
|
||||||
class RecordStatistic(BaseModel):
|
class Statistic(BaseModel):
|
||||||
keys: int
|
keys: int
|
||||||
kpp: float
|
kpp: float
|
||||||
kps: float
|
kps: float
|
||||||
@@ -56,3 +59,17 @@ class RecordStatistic(BaseModel):
|
|||||||
all_clear: int
|
all_clear: int
|
||||||
|
|
||||||
finesse: Finesse
|
finesse: Finesse
|
||||||
|
|
||||||
|
|
||||||
|
class Record(BaseModel):
|
||||||
|
type: Literal['best', 'personal_best', 'recent', 'disputed']
|
||||||
|
|
||||||
|
user: User
|
||||||
|
|
||||||
|
replay_id: str
|
||||||
|
rank: int | None
|
||||||
|
personal_rank: int | None
|
||||||
|
|
||||||
|
statistic: Statistic
|
||||||
|
|
||||||
|
play_at: datetime
|
||||||
|
|||||||
@@ -1,22 +1,12 @@
|
|||||||
from datetime import datetime
|
from .tetrio_record_base import Record as BaseRecord
|
||||||
|
from .tetrio_record_base import Statistic as BaseStatistic
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from .tetrio_record_base import RecordStatistic, User
|
|
||||||
|
|
||||||
|
|
||||||
class Statistic(RecordStatistic):
|
class Statistic(BaseStatistic):
|
||||||
spp: float
|
spp: float
|
||||||
|
|
||||||
level: int
|
level: int
|
||||||
|
|
||||||
|
|
||||||
class Record(BaseModel):
|
class Record(BaseRecord):
|
||||||
user: User
|
|
||||||
|
|
||||||
replay_id: str
|
|
||||||
rank: int | None
|
|
||||||
|
|
||||||
statistic: Statistic
|
statistic: Statistic
|
||||||
|
|
||||||
play_at: datetime
|
|
||||||
|
|||||||
@@ -1,18 +1,5 @@
|
|||||||
from datetime import datetime
|
from .tetrio_record_base import Record as BaseRecord
|
||||||
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from .tetrio_record_base import RecordStatistic as Statistic
|
|
||||||
from .tetrio_record_base import User
|
|
||||||
|
|
||||||
|
|
||||||
class Record(BaseModel):
|
class Record(BaseRecord):
|
||||||
user: User
|
|
||||||
|
|
||||||
time: str
|
time: str
|
||||||
replay_id: str
|
|
||||||
rank: int | None
|
|
||||||
|
|
||||||
statistic: Statistic
|
|
||||||
|
|
||||||
play_at: datetime
|
|
||||||
|
|||||||
@@ -1,71 +1,130 @@
|
|||||||
from asyncio.subprocess import PIPE, create_subprocess_exec
|
from hashlib import sha256
|
||||||
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
from time import time_ns
|
||||||
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
from aiofiles import open
|
||||||
|
from httpx import AsyncClient
|
||||||
from nonebot import get_driver
|
from nonebot import get_driver
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot_plugin_alconna import on_alconna
|
from nonebot_plugin_alconna import Alconna, Args, Option, on_alconna
|
||||||
from nonebot_plugin_localstore import get_data_dir # type: ignore[import-untyped]
|
from nonebot_plugin_localstore import get_cache_file, get_data_dir
|
||||||
|
from rich.progress import Progress
|
||||||
|
|
||||||
driver = get_driver()
|
driver = get_driver()
|
||||||
|
|
||||||
templates_dir = get_data_dir('nonebot_plugin_tetris_stats') / 'templates'
|
TEMPLATES_DIR = get_data_dir('nonebot_plugin_tetris_stats') / 'templates'
|
||||||
|
|
||||||
alc = on_alconna('更新模板', permission=SUPERUSER)
|
alc = on_alconna(Alconna('更新模板', Option('--revision', Args['revision', str], alias={'-R'})), permission=SUPERUSER)
|
||||||
|
|
||||||
|
|
||||||
|
async def download_templates(tag: str) -> Path:
|
||||||
|
logger.info(f'开始下载模板 {tag}')
|
||||||
|
async with AsyncClient() as client:
|
||||||
|
if tag == 'latest':
|
||||||
|
logger.info('目标为 latest, 正在获取最新版本号')
|
||||||
|
tag = (
|
||||||
|
(
|
||||||
|
await client.get(
|
||||||
|
'https://github.com/A-Minos/tetris-stats-templates/releases/latest', follow_redirects=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.url.path.strip('/')
|
||||||
|
.rsplit('/', 1)[-1]
|
||||||
|
)
|
||||||
|
logger.success(f'获取到的最新版本号: {tag}')
|
||||||
|
path = get_cache_file('nonebot_plugin_tetris_stats', f'dist_{time_ns()}.zip')
|
||||||
|
with Progress() as progress:
|
||||||
|
task_id = progress.add_task('[red]Downloading...', total=None)
|
||||||
|
async with (
|
||||||
|
client.stream(
|
||||||
|
'GET',
|
||||||
|
f'https://github.com/A-Minos/tetris-stats-templates/releases/download/{tag}/dist.zip',
|
||||||
|
follow_redirects=True,
|
||||||
|
) as response,
|
||||||
|
open(path, 'wb') as file,
|
||||||
|
):
|
||||||
|
response.raise_for_status()
|
||||||
|
progress.update(task_id, total=int(response.headers.get('content-length', 0)) or None)
|
||||||
|
async for chunk in response.aiter_bytes():
|
||||||
|
await file.write(chunk)
|
||||||
|
progress.update(task_id, advance=len(chunk))
|
||||||
|
logger.success('模板下载完成')
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
async def unzip_templates(zip_path: Path) -> Path:
|
||||||
|
logger.info('开始解压模板')
|
||||||
|
temp_path = TEMPLATES_DIR.parent / f'temp_{time_ns()}'
|
||||||
|
with ZipFile(zip_path) as zip_file:
|
||||||
|
zip_file.extractall(temp_path)
|
||||||
|
zip_path.unlink()
|
||||||
|
logger.success('模板解压完成')
|
||||||
|
return temp_path
|
||||||
|
|
||||||
|
|
||||||
|
async def check_hash(hash_file_path: Path) -> bool:
|
||||||
|
logger.info('开始校验模板哈希值')
|
||||||
|
for i in hash_file_path.read_text().splitlines():
|
||||||
|
file_sha256, file_relative_path = i.split(maxsplit=1)
|
||||||
|
file_path = hash_file_path.parent / file_relative_path
|
||||||
|
hasher = sha256()
|
||||||
|
if not file_path.is_file():
|
||||||
|
logger.error(f'{file_path.name} 不存在或不是文件')
|
||||||
|
return False
|
||||||
|
async with open(file_path, 'rb') as file:
|
||||||
|
while True:
|
||||||
|
chunk = await file.read(65535)
|
||||||
|
if not chunk:
|
||||||
|
break
|
||||||
|
hasher.update(chunk)
|
||||||
|
if hasher.hexdigest() != file_sha256:
|
||||||
|
logger.error(f'{file_path.name} hash 不匹配')
|
||||||
|
return False
|
||||||
|
logger.debug(f'{file_path.name} hash 匹配成功')
|
||||||
|
logger.success('模板哈希值校验成功')
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def init_templates(tag: str) -> bool:
|
||||||
|
logger.info(f'开始初始化模板 {tag}')
|
||||||
|
temp_path = await unzip_templates(await download_templates(tag))
|
||||||
|
if not await check_hash(temp_path / 'hash.sha256'):
|
||||||
|
rmtree(temp_path)
|
||||||
|
return False
|
||||||
|
if TEMPLATES_DIR.exists():
|
||||||
|
logger.info('清除旧模板文件')
|
||||||
|
rmtree(TEMPLATES_DIR)
|
||||||
|
temp_path.rename(TEMPLATES_DIR)
|
||||||
|
logger.info('模板初始化完成')
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def check_tag(tag: str) -> bool:
|
||||||
|
async with AsyncClient() as client:
|
||||||
|
return (
|
||||||
|
await client.get(f'https://github.com/A-Minos/tetris-stats-templates/releases/tag/{tag}')
|
||||||
|
).status_code != HTTPStatus.NOT_FOUND
|
||||||
|
|
||||||
|
|
||||||
@driver.on_startup
|
@driver.on_startup
|
||||||
async def init_templates() -> None:
|
async def _():
|
||||||
try:
|
if (path := (TEMPLATES_DIR / 'hash.sha256')).is_file() and await check_hash(path):
|
||||||
await create_subprocess_exec('git', '--version', stdout=PIPE)
|
logger.success('模板验证成功')
|
||||||
except FileNotFoundError as e:
|
|
||||||
msg = '未找到 git, 请确保 git 已安装并在环境变量中\n安装步骤请参阅: https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git'
|
|
||||||
raise RuntimeError(msg) from e
|
|
||||||
if not templates_dir.exists():
|
|
||||||
logger.info('模板仓库不存在, 正在尝试初始化...')
|
|
||||||
proc = await create_subprocess_exec(
|
|
||||||
'git',
|
|
||||||
'clone',
|
|
||||||
'-b',
|
|
||||||
'gh-pages',
|
|
||||||
'https://github.com/A-Minos/tetris-stats-templates',
|
|
||||||
templates_dir,
|
|
||||||
'--depth=1',
|
|
||||||
stdout=PIPE,
|
|
||||||
stderr=PIPE,
|
|
||||||
)
|
|
||||||
stdout, stderr = await proc.communicate()
|
|
||||||
if proc.returncode != 0:
|
|
||||||
for i in stderr.decode().splitlines():
|
|
||||||
logger.error(i)
|
|
||||||
msg = '初始化模板仓库失败'
|
|
||||||
raise RuntimeError(msg)
|
|
||||||
logger.success('模板仓库初始化成功')
|
|
||||||
return
|
return
|
||||||
proc = await create_subprocess_exec(
|
if not await init_templates('latest'):
|
||||||
'git', 'rev-parse', '--is-inside-work-tree', stdout=PIPE, stderr=PIPE, cwd=templates_dir
|
msg = '模板初始化失败'
|
||||||
)
|
|
||||||
stdout, stderr = await proc.communicate()
|
|
||||||
if proc.returncode != 0:
|
|
||||||
for i in stderr.decode().splitlines():
|
|
||||||
logger.error(i)
|
|
||||||
logger.warning('模板仓库状态异常, 尝试重新初始化')
|
|
||||||
rmtree(templates_dir)
|
|
||||||
await init_templates()
|
|
||||||
return
|
|
||||||
logger.info('正在更新模板仓库...')
|
|
||||||
proc = await create_subprocess_exec('git', 'pull', stdout=PIPE, stderr=PIPE, cwd=templates_dir)
|
|
||||||
stdout, stderr = await proc.communicate()
|
|
||||||
logger.info(stdout.decode().strip())
|
|
||||||
if proc.returncode != 0:
|
|
||||||
for i in stderr.decode().splitlines():
|
|
||||||
logger.error(i)
|
|
||||||
msg = '更新模板仓库失败'
|
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
logger.success('模板仓库更新成功')
|
|
||||||
|
|
||||||
|
|
||||||
@alc.handle()
|
@alc.handle()
|
||||||
async def _():
|
async def _(revision: str | None = None):
|
||||||
await init_templates()
|
if revision is not None and not await check_tag(revision):
|
||||||
await alc.finish('模板仓库更新成功')
|
await alc.finish(f'{revision} 不是模板仓库中的有效标签')
|
||||||
|
logger.info('开始更新模板')
|
||||||
|
if await init_templates(revision or 'latest'):
|
||||||
|
await alc.finish('更新模板成功')
|
||||||
|
await alc.finish('更新模板失败')
|
||||||
|
|||||||
142
poetry.lock
generated
142
poetry.lock
generated
@@ -286,6 +286,20 @@ files = [
|
|||||||
arclet-alconna = ">=1.8.15"
|
arclet-alconna = ">=1.8.15"
|
||||||
nepattern = ">=0.7.3,<1.0.0"
|
nepattern = ">=0.7.3,<1.0.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-lru"
|
||||||
|
version = "2.0.4"
|
||||||
|
description = "Simple LRU cache for asyncio"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8"
|
||||||
|
files = [
|
||||||
|
{file = "async-lru-2.0.4.tar.gz", hash = "sha256:b8a59a5df60805ff63220b2a0c5b5393da5521b113cd5465a44eb037d81a5627"},
|
||||||
|
{file = "async_lru-2.0.4-py3-none-any.whl", hash = "sha256:ff02944ce3c288c5be660c42dbcca0742b32c3b279d6dceda655190240b99224"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""}
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-timeout"
|
name = "async-timeout"
|
||||||
version = "4.0.3"
|
version = "4.0.3"
|
||||||
@@ -1600,44 +1614,44 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mypy"
|
name = "mypy"
|
||||||
version = "1.10.1"
|
version = "1.11.0"
|
||||||
description = "Optional static typing for Python"
|
description = "Optional static typing for Python"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "mypy-1.10.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e36f229acfe250dc660790840916eb49726c928e8ce10fbdf90715090fe4ae02"},
|
{file = "mypy-1.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a3824187c99b893f90c845bab405a585d1ced4ff55421fdf5c84cb7710995229"},
|
||||||
{file = "mypy-1.10.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:51a46974340baaa4145363b9e051812a2446cf583dfaeba124af966fa44593f7"},
|
{file = "mypy-1.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:96f8dbc2c85046c81bcddc246232d500ad729cb720da4e20fce3b542cab91287"},
|
||||||
{file = "mypy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:901c89c2d67bba57aaaca91ccdb659aa3a312de67f23b9dfb059727cce2e2e0a"},
|
{file = "mypy-1.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a5d8d8dd8613a3e2be3eae829ee891b6b2de6302f24766ff06cb2875f5be9c6"},
|
||||||
{file = "mypy-1.10.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0cd62192a4a32b77ceb31272d9e74d23cd88c8060c34d1d3622db3267679a5d9"},
|
{file = "mypy-1.11.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:72596a79bbfb195fd41405cffa18210af3811beb91ff946dbcb7368240eed6be"},
|
||||||
{file = "mypy-1.10.1-cp310-cp310-win_amd64.whl", hash = "sha256:a2cbc68cb9e943ac0814c13e2452d2046c2f2b23ff0278e26599224cf164e78d"},
|
{file = "mypy-1.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:35ce88b8ed3a759634cb4eb646d002c4cef0a38f20565ee82b5023558eb90c00"},
|
||||||
{file = "mypy-1.10.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:bd6f629b67bb43dc0d9211ee98b96d8dabc97b1ad38b9b25f5e4c4d7569a0c6a"},
|
{file = "mypy-1.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:98790025861cb2c3db8c2f5ad10fc8c336ed2a55f4daf1b8b3f877826b6ff2eb"},
|
||||||
{file = "mypy-1.10.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a1bbb3a6f5ff319d2b9d40b4080d46cd639abe3516d5a62c070cf0114a457d84"},
|
{file = "mypy-1.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:25bcfa75b9b5a5f8d67147a54ea97ed63a653995a82798221cca2a315c0238c1"},
|
||||||
{file = "mypy-1.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8edd4e9bbbc9d7b79502eb9592cab808585516ae1bcc1446eb9122656c6066f"},
|
{file = "mypy-1.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0bea2a0e71c2a375c9fa0ede3d98324214d67b3cbbfcbd55ac8f750f85a414e3"},
|
||||||
{file = "mypy-1.10.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:6166a88b15f1759f94a46fa474c7b1b05d134b1b61fca627dd7335454cc9aa6b"},
|
{file = "mypy-1.11.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d2b3d36baac48e40e3064d2901f2fbd2a2d6880ec6ce6358825c85031d7c0d4d"},
|
||||||
{file = "mypy-1.10.1-cp311-cp311-win_amd64.whl", hash = "sha256:5bb9cd11c01c8606a9d0b83ffa91d0b236a0e91bc4126d9ba9ce62906ada868e"},
|
{file = "mypy-1.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:d8e2e43977f0e09f149ea69fd0556623919f816764e26d74da0c8a7b48f3e18a"},
|
||||||
{file = "mypy-1.10.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d8681909f7b44d0b7b86e653ca152d6dff0eb5eb41694e163c6092124f8246d7"},
|
{file = "mypy-1.11.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:1d44c1e44a8be986b54b09f15f2c1a66368eb43861b4e82573026e04c48a9e20"},
|
||||||
{file = "mypy-1.10.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:378c03f53f10bbdd55ca94e46ec3ba255279706a6aacaecac52ad248f98205d3"},
|
{file = "mypy-1.11.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cea3d0fb69637944dd321f41bc896e11d0fb0b0aa531d887a6da70f6e7473aba"},
|
||||||
{file = "mypy-1.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bacf8f3a3d7d849f40ca6caea5c055122efe70e81480c8328ad29c55c69e93e"},
|
{file = "mypy-1.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a83ec98ae12d51c252be61521aa5731f5512231d0b738b4cb2498344f0b840cd"},
|
||||||
{file = "mypy-1.10.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:701b5f71413f1e9855566a34d6e9d12624e9e0a8818a5704d74d6b0402e66c04"},
|
{file = "mypy-1.11.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:c7b73a856522417beb78e0fb6d33ef89474e7a622db2653bc1285af36e2e3e3d"},
|
||||||
{file = "mypy-1.10.1-cp312-cp312-win_amd64.whl", hash = "sha256:3c4c2992f6ea46ff7fce0072642cfb62af7a2484efe69017ed8b095f7b39ef31"},
|
{file = "mypy-1.11.0-cp312-cp312-win_amd64.whl", hash = "sha256:f2268d9fcd9686b61ab64f077be7ffbc6fbcdfb4103e5dd0cc5eaab53a8886c2"},
|
||||||
{file = "mypy-1.10.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:604282c886497645ffb87b8f35a57ec773a4a2721161e709a4422c1636ddde5c"},
|
{file = "mypy-1.11.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:940bfff7283c267ae6522ef926a7887305945f716a7704d3344d6d07f02df850"},
|
||||||
{file = "mypy-1.10.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37fd87cab83f09842653f08de066ee68f1182b9b5282e4634cdb4b407266bade"},
|
{file = "mypy-1.11.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:14f9294528b5f5cf96c721f231c9f5b2733164e02c1c018ed1a0eff8a18005ac"},
|
||||||
{file = "mypy-1.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8addf6313777dbb92e9564c5d32ec122bf2c6c39d683ea64de6a1fd98b90fe37"},
|
{file = "mypy-1.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7b54c27783991399046837df5c7c9d325d921394757d09dbcbf96aee4649fe9"},
|
||||||
{file = "mypy-1.10.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:5cc3ca0a244eb9a5249c7c583ad9a7e881aa5d7b73c35652296ddcdb33b2b9c7"},
|
{file = "mypy-1.11.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:65f190a6349dec29c8d1a1cd4aa71284177aee5949e0502e6379b42873eddbe7"},
|
||||||
{file = "mypy-1.10.1-cp38-cp38-win_amd64.whl", hash = "sha256:1b3a2ffce52cc4dbaeee4df762f20a2905aa171ef157b82192f2e2f368eec05d"},
|
{file = "mypy-1.11.0-cp38-cp38-win_amd64.whl", hash = "sha256:dbe286303241fea8c2ea5466f6e0e6a046a135a7e7609167b07fd4e7baf151bf"},
|
||||||
{file = "mypy-1.10.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fe85ed6836165d52ae8b88f99527d3d1b2362e0cb90b005409b8bed90e9059b3"},
|
{file = "mypy-1.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:104e9c1620c2675420abd1f6c44bab7dd33cc85aea751c985006e83dcd001095"},
|
||||||
{file = "mypy-1.10.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c2ae450d60d7d020d67ab440c6e3fae375809988119817214440033f26ddf7bf"},
|
{file = "mypy-1.11.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f006e955718ecd8d159cee9932b64fba8f86ee6f7728ca3ac66c3a54b0062abe"},
|
||||||
{file = "mypy-1.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6be84c06e6abd72f960ba9a71561c14137a583093ffcf9bbfaf5e613d63fa531"},
|
{file = "mypy-1.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:becc9111ca572b04e7e77131bc708480cc88a911adf3d0239f974c034b78085c"},
|
||||||
{file = "mypy-1.10.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2189ff1e39db399f08205e22a797383613ce1cb0cb3b13d8bcf0170e45b96cc3"},
|
{file = "mypy-1.11.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6801319fe76c3f3a3833f2b5af7bd2c17bb93c00026a2a1b924e6762f5b19e13"},
|
||||||
{file = "mypy-1.10.1-cp39-cp39-win_amd64.whl", hash = "sha256:97a131ee36ac37ce9581f4220311247ab6cba896b4395b9c87af0675a13a755f"},
|
{file = "mypy-1.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:c1a184c64521dc549324ec6ef7cbaa6b351912be9cb5edb803c2808a0d7e85ac"},
|
||||||
{file = "mypy-1.10.1-py3-none-any.whl", hash = "sha256:71d8ac0b906354ebda8ef1673e5fde785936ac1f29ff6987c7483cfbd5a4235a"},
|
{file = "mypy-1.11.0-py3-none-any.whl", hash = "sha256:56913ec8c7638b0091ef4da6fcc9136896914a9d60d54670a75880c3e5b99ace"},
|
||||||
{file = "mypy-1.10.1.tar.gz", hash = "sha256:1f8f492d7db9e3593ef42d4f115f04e556130f2819ad33ab84551403e97dd4c0"},
|
{file = "mypy-1.11.0.tar.gz", hash = "sha256:93743608c7348772fdc717af4aeee1997293a1ad04bc0ea6efa15bf65385c538"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
mypy-extensions = ">=1.0.0"
|
mypy-extensions = ">=1.0.0"
|
||||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||||
typing-extensions = ">=4.1.0"
|
typing-extensions = ">=4.6.0"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
dmypy = ["psutil (>=4.0)"]
|
dmypy = ["psutil (>=4.0)"]
|
||||||
@@ -1750,17 +1764,17 @@ nonebot2 = ">=2.3.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-plugin-alconna"
|
name = "nonebot-plugin-alconna"
|
||||||
version = "0.49.0"
|
version = "0.50.2"
|
||||||
description = "Alconna Adapter for Nonebot"
|
description = "Alconna Adapter for Nonebot"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.9"
|
python-versions = ">=3.9"
|
||||||
files = [
|
files = [
|
||||||
{file = "nonebot_plugin_alconna-0.49.0-py3-none-any.whl", hash = "sha256:a9733a37c521373d9dd71752ab0e9cd2338c385ef9871c8e3f2ad178b2f1668f"},
|
{file = "nonebot_plugin_alconna-0.50.2-py3-none-any.whl", hash = "sha256:be641eaf539f6f9dfb2398be80e994fa27814064eeed89e7a46a03754756dfc1"},
|
||||||
{file = "nonebot_plugin_alconna-0.49.0.tar.gz", hash = "sha256:5060819b76d05c24d944e17b6a10de52e8821063d15220ab65083cda97c05706"},
|
{file = "nonebot_plugin_alconna-0.50.2.tar.gz", hash = "sha256:ebae23723cee5cbbc350aa864d9e3d95cb1ab8324ba8674130df3302066277b1"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
arclet-alconna = ">=1.8.16"
|
arclet-alconna = ">=1.8.19"
|
||||||
arclet-alconna-tools = ">=0.7.6"
|
arclet-alconna-tools = ">=0.7.6"
|
||||||
importlib-metadata = ">=4.13.0"
|
importlib-metadata = ">=4.13.0"
|
||||||
nepattern = ">=0.7.4"
|
nepattern = ">=0.7.4"
|
||||||
@@ -1802,13 +1816,13 @@ typing-extensions = ">=4.0.0,<5.0.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-plugin-orm"
|
name = "nonebot-plugin-orm"
|
||||||
version = "0.7.4"
|
version = "0.7.5"
|
||||||
description = "SQLAlchemy ORM support for nonebot"
|
description = "SQLAlchemy ORM support for nonebot"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "<4.0,>=3.8"
|
python-versions = "<4.0,>=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "nonebot_plugin_orm-0.7.4-py3-none-any.whl", hash = "sha256:e2d3f3ba6b7bf22236b9481015cbc13b184f22450fe7abe2f7a65ed128bf2d9e"},
|
{file = "nonebot_plugin_orm-0.7.5-py3-none-any.whl", hash = "sha256:a16419950c1bf72c97c199fdc508a8380d438fa55cc129a5ca815cf8aa5411ac"},
|
||||||
{file = "nonebot_plugin_orm-0.7.4.tar.gz", hash = "sha256:67ff5f358249bd9413d958ad002dea1749eb2530e1038f633c1dd044dd5816f3"},
|
{file = "nonebot_plugin_orm-0.7.5.tar.gz", hash = "sha256:fe29be515bf07fa783d894d784d9e80cb26ff8f43222db88660d9e22e2e7ca24"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@@ -2248,18 +2262,18 @@ xmp = ["defusedxml"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "playwright"
|
name = "playwright"
|
||||||
version = "1.45.0"
|
version = "1.45.1"
|
||||||
description = "A high-level API to automate web browsers"
|
description = "A high-level API to automate web browsers"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "playwright-1.45.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:7d49aee5907d8e72060f04bc299cb6851c2dc44cb227540ade89d7aa529e907a"},
|
{file = "playwright-1.45.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:360607e37c00cdf97c74317f010e106ac4671aeaec6a192431dd71a30941da9d"},
|
||||||
{file = "playwright-1.45.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:210c9f848820f58b5b5ed48047748620b780ca3acc3e2b7560dafb2bfdd6d90a"},
|
{file = "playwright-1.45.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:20adc2abf164c5e8969f9066011b152e12c210549edec78cd05bd0e9cf4135b7"},
|
||||||
{file = "playwright-1.45.0-py3-none-macosx_11_0_universal2.whl", hash = "sha256:13b5398831f5499580e819ddc996633446a93bf88029e89451e51da188e16ae3"},
|
{file = "playwright-1.45.1-py3-none-macosx_11_0_universal2.whl", hash = "sha256:5f047cdc6accf4c7084dfc7587a2a5ef790cddc44cbb111e471293c5a91119db"},
|
||||||
{file = "playwright-1.45.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:0ba5a39f25fb9b9cf1bd48678f44536a29f6d83376329de2dee1567dac220afe"},
|
{file = "playwright-1.45.1-py3-none-manylinux1_x86_64.whl", hash = "sha256:f06f6659abe0abf263e5f6661d379fbf85c112745dd31d82332ceae914f58df7"},
|
||||||
{file = "playwright-1.45.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b09fa76614ba2926d45a4c0581f710c13652d5e32290ba6a1490fbafff7f0be8"},
|
{file = "playwright-1.45.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:87dc3b3d17e12c68830c29b7fdf5e93315221bbb4c6090e83e967e154e2c1828"},
|
||||||
{file = "playwright-1.45.0-py3-none-win32.whl", hash = "sha256:97a7d53af89af54208b69c051046b462675fcf5b93f7fbfb7c0fa7f813424ee2"},
|
{file = "playwright-1.45.1-py3-none-win32.whl", hash = "sha256:2b8f517886ef1e2151982f6e7be84be3ef7d8135bdcf8ee705b4e4e99566e866"},
|
||||||
{file = "playwright-1.45.0-py3-none-win_amd64.whl", hash = "sha256:701db496928429aec103739e48e3110806bd5cf49456cc95b89f28e1abda71da"},
|
{file = "playwright-1.45.1-py3-none-win_amd64.whl", hash = "sha256:0d236cf427784e77de352ba1b7d700693c5fe455b8e5f627f6d84ad5b84b5bf5"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@@ -2693,29 +2707,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruff"
|
name = "ruff"
|
||||||
version = "0.5.2"
|
version = "0.5.5"
|
||||||
description = "An extremely fast Python linter and code formatter, written in Rust."
|
description = "An extremely fast Python linter and code formatter, written in Rust."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
{file = "ruff-0.5.2-py3-none-linux_armv6l.whl", hash = "sha256:7bab8345df60f9368d5f4594bfb8b71157496b44c30ff035d1d01972e764d3be"},
|
{file = "ruff-0.5.5-py3-none-linux_armv6l.whl", hash = "sha256:605d589ec35d1da9213a9d4d7e7a9c761d90bba78fc8790d1c5e65026c1b9eaf"},
|
||||||
{file = "ruff-0.5.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:1aa7acad382ada0189dbe76095cf0a36cd0036779607c397ffdea16517f535b1"},
|
{file = "ruff-0.5.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:00817603822a3e42b80f7c3298c8269e09f889ee94640cd1fc7f9329788d7bf8"},
|
||||||
{file = "ruff-0.5.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:aec618d5a0cdba5592c60c2dee7d9c865180627f1a4a691257dea14ac1aa264d"},
|
{file = "ruff-0.5.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:187a60f555e9f865a2ff2c6984b9afeffa7158ba6e1eab56cb830404c942b0f3"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0b62adc5ce81780ff04077e88bac0986363e4a3260ad3ef11ae9c14aa0e67ef"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fe26fc46fa8c6e0ae3f47ddccfbb136253c831c3289bba044befe68f467bfb16"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dc42ebf56ede83cb080a50eba35a06e636775649a1ffd03dc986533f878702a3"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4ad25dd9c5faac95c8e9efb13e15803cd8bbf7f4600645a60ffe17c73f60779b"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c15c6e9f88c67ffa442681365d11df38afb11059fc44238e71a9d9f1fd51de70"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f70737c157d7edf749bcb952d13854e8f745cec695a01bdc6e29c29c288fc36e"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d3de9a5960f72c335ef00763d861fc5005ef0644cb260ba1b5a115a102157251"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:cfd7de17cef6ab559e9f5ab859f0d3296393bc78f69030967ca4d87a541b97a0"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fe5a968ae933e8f7627a7b2fc8893336ac2be0eb0aace762d3421f6e8f7b7f83"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a09b43e02f76ac0145f86a08e045e2ea452066f7ba064fd6b0cdccb486f7c3e7"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a04f54a9018f75615ae52f36ea1c5515e356e5d5e214b22609ddb546baef7132"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d0b856cb19c60cd40198be5d8d4b556228e3dcd545b4f423d1ad812bfdca5884"},
|
||||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ed02fb52e3741f0738db5f93e10ae0fb5c71eb33a4f2ba87c9a2fa97462a649"},
|
{file = "ruff-0.5.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3687d002f911e8a5faf977e619a034d159a8373514a587249cc00f211c67a091"},
|
||||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3cf8fe659f6362530435d97d738eb413e9f090e7e993f88711b0377fbdc99f60"},
|
{file = "ruff-0.5.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ac9dc814e510436e30d0ba535f435a7f3dc97f895f844f5b3f347ec8c228a523"},
|
||||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:237a37e673e9f3cbfff0d2243e797c4862a44c93d2f52a52021c1a1b0899f846"},
|
{file = "ruff-0.5.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:af9bdf6c389b5add40d89b201425b531e0a5cceb3cfdcc69f04d3d531c6be74f"},
|
||||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:2a2949ce7c1cbd8317432ada80fe32156df825b2fd611688814c8557824ef060"},
|
{file = "ruff-0.5.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d40a8533ed545390ef8315b8e25c4bb85739b90bd0f3fe1280a29ae364cc55d8"},
|
||||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:481af57c8e99da92ad168924fd82220266043c8255942a1cb87958b108ac9335"},
|
{file = "ruff-0.5.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:cab904683bf9e2ecbbe9ff235bfe056f0eba754d0168ad5407832928d579e7ab"},
|
||||||
{file = "ruff-0.5.2-py3-none-win32.whl", hash = "sha256:f1aea290c56d913e363066d83d3fc26848814a1fed3d72144ff9c930e8c7c718"},
|
{file = "ruff-0.5.5-py3-none-win32.whl", hash = "sha256:696f18463b47a94575db635ebb4c178188645636f05e934fdf361b74edf1bb2d"},
|
||||||
{file = "ruff-0.5.2-py3-none-win_amd64.whl", hash = "sha256:8532660b72b5d94d2a0a7a27ae7b9b40053662d00357bb2a6864dd7e38819084"},
|
{file = "ruff-0.5.5-py3-none-win_amd64.whl", hash = "sha256:50f36d77f52d4c9c2f1361ccbfbd09099a1b2ea5d2b2222c586ab08885cf3445"},
|
||||||
{file = "ruff-0.5.2-py3-none-win_arm64.whl", hash = "sha256:73439805c5cb68f364d826a5c5c4b6c798ded6b7ebaa4011f01ce6c94e4d5583"},
|
{file = "ruff-0.5.5-py3-none-win_arm64.whl", hash = "sha256:3191317d967af701f1b73a31ed5788795936e423b7acce82a2b63e26eb3e89d6"},
|
||||||
{file = "ruff-0.5.2.tar.gz", hash = "sha256:2c0df2d2de685433794a14d8d2e240df619b748fbe3367346baa519d8e6f1ca2"},
|
{file = "ruff-0.5.5.tar.gz", hash = "sha256:cc5516bdb4858d972fbc31d246bdb390eab8df1a26e2353be2dbc0c2d7f5421a"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3755,4 +3769,4 @@ cffi = ["cffi (>=1.11)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "e113b54aa85e884a536bdc47c71884ca21d31441f651b96a94ce3b400e9de1d5"
|
content-hash = "9090ada80aca0dc6618cb58cd052cff4bc4d691c936bf9cd748655e8c31c658a"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = 'nonebot-plugin-tetris-stats'
|
name = 'nonebot-plugin-tetris-stats'
|
||||||
version = '1.4.0'
|
version = '1.4.2'
|
||||||
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
|
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
|
||||||
authors = ['scdhh <wallfjjd@gmail.com>']
|
authors = ['scdhh <wallfjjd@gmail.com>']
|
||||||
readme = 'README.md'
|
readme = 'README.md'
|
||||||
@@ -22,6 +22,7 @@ nonebot-plugin-userinfo = "^0.2.4"
|
|||||||
aiocache = "^0.12.2"
|
aiocache = "^0.12.2"
|
||||||
aiofiles = ">=23.2.1,<25.0.0"
|
aiofiles = ">=23.2.1,<25.0.0"
|
||||||
arclet-alconna = "^1.8.19"
|
arclet-alconna = "^1.8.19"
|
||||||
|
async-lru = "^2.0.4"
|
||||||
httpx = "^0.27.0"
|
httpx = "^0.27.0"
|
||||||
jinja2 = "^3.1.3"
|
jinja2 = "^3.1.3"
|
||||||
lxml = '^5.1.0'
|
lxml = '^5.1.0'
|
||||||
|
|||||||
Reference in New Issue
Block a user