mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
* ✨ 适配 v1 tetrio 的 Trending * 🗃️ 添加 compare_delta 配置项 * 🗃️ 添加 TETRIOLeagueUserMap 索引表 * ✨ 添加对比时间配置项 * ✨ 添加 compare_delta 解析函数 * ✨ 添加 Trending 类的 compare 方法 * 🗃️ 移除不正确的复合索引 * ✨ 定时任务拉取tl数据时同步更新索引 * ✨ 适配 trending * 🐛 修复 find_entry 在无 uid 时的索引返回逻辑 * 📝 修正 compare_delta 迁移父迁移注释 * 🗃️ 为非 PostgreSQL 回填迁移补充外键约束 * 🔒 迁移中使用参数绑定设置 PG 内存参数 * ✨ 修正 Trends 的 vs 为 adpm * 🐛 修正获取玩家 ID 的范围
104 lines
3.1 KiB
Python
104 lines
3.1 KiB
Python
from arclet.alconna import Arg, ArgFlag
|
|
from nonebot_plugin_alconna import Args, At, Option, Subcommand
|
|
|
|
from ...utils.duration import parse_duration
|
|
from ...utils.exception import MessageFormatError
|
|
from ...utils.typedefs import Me
|
|
from .. import add_block_handlers, alc, command
|
|
from .api import Player
|
|
from .constant import USER_NAME
|
|
|
|
|
|
def get_player(teaid_or_name: str) -> Player | MessageFormatError:
|
|
if (
|
|
teaid_or_name.startswith(('onebot-', 'qqguild-', 'kook-', 'discord-'))
|
|
and teaid_or_name.split('-', maxsplit=1)[1].isdigit()
|
|
):
|
|
return Player(teaid=teaid_or_name, trust=True)
|
|
if USER_NAME.match(teaid_or_name) and not teaid_or_name.isdigit() and 2 <= len(teaid_or_name) <= 18: # noqa: PLR2004
|
|
return Player(user_name=teaid_or_name, trust=True)
|
|
return MessageFormatError('用户名/ID不合法')
|
|
|
|
|
|
command.add(
|
|
Subcommand(
|
|
'TOS',
|
|
Subcommand(
|
|
'bind',
|
|
Args(
|
|
Arg(
|
|
'account',
|
|
get_player,
|
|
notice='茶服 用户名 / ID',
|
|
flags=[ArgFlag.HIDDEN],
|
|
)
|
|
),
|
|
help_text='绑定 茶服 账号',
|
|
),
|
|
Subcommand(
|
|
'unbind',
|
|
help_text='解除绑定 TOS 账号',
|
|
),
|
|
Subcommand(
|
|
'config',
|
|
Option(
|
|
'--default-compare',
|
|
Arg('compare', parse_duration, notice='对比时间距离'),
|
|
alias=['-DC', 'DefaultCompare'],
|
|
help_text='设置默认对比时间距离',
|
|
),
|
|
help_text='茶服 查询个性化配置',
|
|
),
|
|
Subcommand(
|
|
'query',
|
|
Args(
|
|
Arg(
|
|
'target',
|
|
At | Me,
|
|
notice='@想要查询的人 / 自己',
|
|
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
|
),
|
|
Arg(
|
|
'account',
|
|
get_player,
|
|
notice='茶服 用户名 / TeaID',
|
|
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
|
|
),
|
|
),
|
|
Option(
|
|
'--compare',
|
|
Arg('compare', parse_duration),
|
|
alias=['-C'],
|
|
help_text='指定对比时间距离',
|
|
),
|
|
help_text='查询 茶服 游戏信息',
|
|
),
|
|
help_text='茶服 游戏相关指令',
|
|
)
|
|
)
|
|
|
|
alc.shortcut(
|
|
'(?i:tos|茶服)(?i:绑定|绑|bind)',
|
|
command='tstats TOS bind',
|
|
humanized='茶服绑定',
|
|
)
|
|
alc.shortcut(
|
|
'(?i:tos|茶服)(?i:解除绑定|解绑|unbind)',
|
|
command='tstats TOS unbind',
|
|
humanized='茶服解绑',
|
|
)
|
|
alc.shortcut(
|
|
'(?i:tos|茶服)(?i:查询|查|query|stats)',
|
|
command='tstats TOS query',
|
|
humanized='茶服查',
|
|
)
|
|
alc.shortcut(
|
|
'(?i:tos|茶服)(?i:配置|配|config)',
|
|
command='tstats TOS config',
|
|
humanized='茶服配置',
|
|
)
|
|
|
|
add_block_handlers(alc.assign('TOS.query'))
|
|
|
|
from . import bind, config, query, unbind # noqa: E402, F401
|