mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 适配 TETR.IO 新赛季 (#380)
* ✨ 新 api 的 schemas * 👽️ 更新新赛季 api 的 schemas * ➕ 添加依赖 async-lru * 👽️ 更新新赛季 api 封装 * 👽️ 适配新赛季 api 40l * 🐛 api_type 忘记更新了 * 👽️ 适配新赛季 api blitz * 👽️ 适配新赛季 api bind * 🔥 暂时删除一些指令 等待新赛季开始 * 🚨 auto fix by pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,9 +3,12 @@ from nonebot_plugin_alconna import At
|
||||
|
||||
from ...utils.exception import MessageFormatError
|
||||
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.typing import ValidRank
|
||||
|
||||
# from .api.typing import ValidRank
|
||||
from .constant import USER_ID, USER_NAME
|
||||
from .typing import Template
|
||||
|
||||
@@ -33,30 +36,30 @@ command.add(
|
||||
),
|
||||
help_text='绑定 TETR.IO 账号',
|
||||
),
|
||||
Subcommand(
|
||||
'query',
|
||||
Args(
|
||||
Arg(
|
||||
'target',
|
||||
At | Me,
|
||||
notice='@想要查询的人 / 自己',
|
||||
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||
),
|
||||
Arg(
|
||||
'account',
|
||||
get_player,
|
||||
notice='TETR.IO 用户名 / ID',
|
||||
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||
),
|
||||
),
|
||||
Option(
|
||||
'--template',
|
||||
Arg('template', Template),
|
||||
alias=['-T'],
|
||||
help_text='要使用的查询模板',
|
||||
),
|
||||
help_text='查询 TETR.IO 游戏信息',
|
||||
),
|
||||
# Subcommand(
|
||||
# 'query',
|
||||
# Args(
|
||||
# Arg(
|
||||
# 'target',
|
||||
# At | Me,
|
||||
# notice='@想要查询的人 / 自己',
|
||||
# flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||
# ),
|
||||
# Arg(
|
||||
# 'account',
|
||||
# get_player,
|
||||
# notice='TETR.IO 用户名 / ID',
|
||||
# flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
||||
# ),
|
||||
# ),
|
||||
# Option(
|
||||
# '--template',
|
||||
# Arg('template', Template),
|
||||
# alias=['-T'],
|
||||
# help_text='要使用的查询模板',
|
||||
# ),
|
||||
# help_text='查询 TETR.IO 游戏信息',
|
||||
# ),
|
||||
Subcommand(
|
||||
'record',
|
||||
Option(
|
||||
@@ -82,27 +85,33 @@ command.add(
|
||||
),
|
||||
),
|
||||
),
|
||||
Subcommand(
|
||||
'list',
|
||||
Option('--max-tr', Arg('max_tr', float), help_text='TR的上限'),
|
||||
Option('--min-tr', Arg('min_tr', float), help_text='TR的下限'),
|
||||
Option('--limit', Arg('limit', int), help_text='查询数量'),
|
||||
Option('--country', Arg('country', str), help_text='国家代码'),
|
||||
help_text='查询 TETR.IO 段位排行榜',
|
||||
),
|
||||
Subcommand(
|
||||
'rank',
|
||||
Option(
|
||||
'--all',
|
||||
dest='all',
|
||||
),
|
||||
Option(
|
||||
'--detail',
|
||||
Arg('rank', ValidRank),
|
||||
alias=['-D'],
|
||||
),
|
||||
help_text='查询 TETR.IO 段位信息',
|
||||
),
|
||||
# Subcommand(
|
||||
# 'list',
|
||||
# Option('--max-tr', Arg('max_tr', float), help_text='TR的上限'),
|
||||
# Option('--min-tr', Arg('min_tr', float), help_text='TR的下限'),
|
||||
# Option('--limit', Arg('limit', int), help_text='查询数量'),
|
||||
# Option('--country', Arg('country', str), help_text='国家代码'),
|
||||
# help_text='查询 TETR.IO 段位排行榜',
|
||||
# ),
|
||||
# Subcommand(
|
||||
# 'rank',
|
||||
# Subcommand(
|
||||
# '--all',
|
||||
# Option(
|
||||
# '--template',
|
||||
# Arg('template', Template),
|
||||
# alias=['-T'],
|
||||
# help_text='要使用的查询模板',
|
||||
# ),
|
||||
# dest='all',
|
||||
# ),
|
||||
# Option(
|
||||
# '--detail',
|
||||
# Arg('rank', ValidRank),
|
||||
# alias=['-D'],
|
||||
# ),
|
||||
# help_text='查询 TETR.IO 段位信息',
|
||||
# ),
|
||||
Subcommand(
|
||||
'config',
|
||||
Option(
|
||||
@@ -111,18 +120,19 @@ command.add(
|
||||
alias=['-DT', 'DefaultTemplate'],
|
||||
),
|
||||
),
|
||||
alias=['TETRIO', 'tetr.io', 'tetrio', 'io'],
|
||||
dest='TETRIO',
|
||||
help_text='TETR.IO 游戏相关指令',
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def rank_wrapper(slot: int | str, content: str | None):
|
||||
if slot == 'rank' and not content:
|
||||
return '--all'
|
||||
if content is not None:
|
||||
return f'--detail {content.lower()}'
|
||||
return content
|
||||
# def rank_wrapper(slot: int | str, content: str | None):
|
||||
# if slot == 'rank' and not content:
|
||||
# return '--all'
|
||||
# if content is not None:
|
||||
# return f'--detail {content.lower()}'
|
||||
# return content
|
||||
|
||||
|
||||
alc.shortcut(
|
||||
@@ -130,11 +140,11 @@ alc.shortcut(
|
||||
command='tstats TETR.IO bind',
|
||||
humanized='io绑定',
|
||||
)
|
||||
alc.shortcut(
|
||||
'(?i:io)(?i:查询|查|query|stats)',
|
||||
command='tstats TETR.IO query',
|
||||
humanized='io查',
|
||||
)
|
||||
# alc.shortcut(
|
||||
# '(?i:io)(?i:查询|查|query|stats)',
|
||||
# command='tstats TETR.IO query',
|
||||
# humanized='io查',
|
||||
# )
|
||||
alc.shortcut(
|
||||
'(?i:io)(?i:记录|record)(?i:40l)',
|
||||
command='tstats TETR.IO record --40l',
|
||||
@@ -145,36 +155,37 @@ alc.shortcut(
|
||||
command='tstats TETR.IO record --blitz',
|
||||
humanized='io记录blitz',
|
||||
)
|
||||
alc.shortcut(
|
||||
r'(?i:io)(?i:段位|段|rank)\s*(?P<rank>[a-zA-Z+-]{0,2})',
|
||||
command='tstats TETR.IO rank {rank}',
|
||||
humanized='iorank',
|
||||
fuzzy=False,
|
||||
wrapper=rank_wrapper,
|
||||
)
|
||||
# alc.shortcut(
|
||||
# r'(?i:io)(?i:段位|段|rank)\s*(?P<rank>[a-zA-Z+-]{0,2})',
|
||||
# command='tstats TETR.IO rank {rank}',
|
||||
# humanized='iorank',
|
||||
# fuzzy=False,
|
||||
# wrapper=rank_wrapper,
|
||||
# )
|
||||
alc.shortcut(
|
||||
'(?i:io)(?i:配置|配|config)',
|
||||
command='tstats TETR.IO config',
|
||||
humanized='io配置',
|
||||
)
|
||||
|
||||
alc.shortcut(
|
||||
'fkosk',
|
||||
command='tstats TETR.IO query',
|
||||
arguments=['我'],
|
||||
fuzzy=False,
|
||||
humanized='An Easter egg!',
|
||||
)
|
||||
# alc.shortcut(
|
||||
# 'fkosk',
|
||||
# command='tstats TETR.IO query',
|
||||
# arguments=['我'],
|
||||
# fuzzy=False,
|
||||
# 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__ = [
|
||||
'bind',
|
||||
'config',
|
||||
'list',
|
||||
'query',
|
||||
'rank',
|
||||
# 'list',
|
||||
# 'query',
|
||||
# 'rank',
|
||||
'record',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user