mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 为 TETR.IO config record 添加命令历史记录
This commit is contained in:
@@ -1,15 +1,25 @@
|
|||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
||||||
from nonebot_plugin_orm import async_scoped_session
|
from nonebot_plugin_orm import async_scoped_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 # type: ignore[import-untyped]
|
from nonebot_plugin_user import User # type: ignore[import-untyped]
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
from ...db import trigger
|
||||||
from . import alc
|
from . import alc
|
||||||
|
from .constant import GAME_TYPE
|
||||||
from .models import TETRIOUserConfig
|
from .models import TETRIOUserConfig
|
||||||
from .typing import Template
|
from .typing import Template
|
||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.config')
|
@alc.assign('TETRIO.config')
|
||||||
async def _(user: User, session: async_scoped_session, template: Template):
|
async def _(user: User, session: async_scoped_session, event_session: EventSession, template: Template):
|
||||||
|
async with trigger(
|
||||||
|
session_persist_id=await get_session_persist_id(event_session),
|
||||||
|
game_platform=GAME_TYPE,
|
||||||
|
command_type='config',
|
||||||
|
command_args=[],
|
||||||
|
):
|
||||||
config = (await session.scalars(select(TETRIOUserConfig).where(TETRIOUserConfig.id == user.id))).one_or_none()
|
config = (await session.scalars(select(TETRIOUserConfig).where(TETRIOUserConfig.id == user.id))).one_or_none()
|
||||||
if config is None:
|
if config is None:
|
||||||
config = TETRIOUserConfig(id=user.id, query_template=template)
|
config = TETRIOUserConfig(id=user.id, query_template=template)
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ from nonebot_plugin_alconna import At
|
|||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
||||||
from nonebot_plugin_orm import get_session
|
from nonebot_plugin_orm import get_session
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
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 get_user # type: ignore[import-untyped]
|
from nonebot_plugin_user import get_user # type: ignore[import-untyped]
|
||||||
|
|
||||||
from ....db import query_bind_info
|
from ....db import query_bind_info, trigger
|
||||||
from ....utils.exception import RecordNotFoundError
|
from ....utils.exception import RecordNotFoundError
|
||||||
from ....utils.host import HostPage, get_self_netloc
|
from ....utils.host import HostPage, get_self_netloc
|
||||||
from ....utils.metrics import get_metrics
|
from ....utils.metrics import get_metrics
|
||||||
@@ -34,6 +35,12 @@ async def _(
|
|||||||
target: At | Me,
|
target: At | Me,
|
||||||
event_session: EventSession,
|
event_session: EventSession,
|
||||||
):
|
):
|
||||||
|
async with trigger(
|
||||||
|
session_persist_id=await get_session_persist_id(event_session),
|
||||||
|
game_platform=GAME_TYPE,
|
||||||
|
command_type='bind',
|
||||||
|
command_args=[],
|
||||||
|
):
|
||||||
async with get_session() as session:
|
async with get_session() as session:
|
||||||
bind = await query_bind_info(
|
bind = await query_bind_info(
|
||||||
session=session,
|
session=session,
|
||||||
@@ -50,7 +57,13 @@ async def _(
|
|||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.record.blitz')
|
@alc.assign('TETRIO.record.blitz')
|
||||||
async def _(account: Player):
|
async def _(account: Player, event_session: EventSession):
|
||||||
|
async with trigger(
|
||||||
|
session_persist_id=await get_session_persist_id(event_session),
|
||||||
|
game_platform=GAME_TYPE,
|
||||||
|
command_type='bind',
|
||||||
|
command_args=[],
|
||||||
|
):
|
||||||
await UniMessage.image(raw=await make_blitz_image(account)).finish()
|
await UniMessage.image(raw=await make_blitz_image(account)).finish()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ from nonebot_plugin_alconna import At
|
|||||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
||||||
from nonebot_plugin_orm import get_session
|
from nonebot_plugin_orm import get_session
|
||||||
from nonebot_plugin_session import EventSession # type: ignore[import-untyped]
|
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 get_user # type: ignore[import-untyped]
|
from nonebot_plugin_user import get_user # type: ignore[import-untyped]
|
||||||
|
|
||||||
from ....db import query_bind_info
|
from ....db import query_bind_info, trigger
|
||||||
from ....utils.exception import RecordNotFoundError
|
from ....utils.exception import RecordNotFoundError
|
||||||
from ....utils.host import HostPage, get_self_netloc
|
from ....utils.host import HostPage, get_self_netloc
|
||||||
from ....utils.metrics import get_metrics
|
from ....utils.metrics import get_metrics
|
||||||
@@ -34,6 +35,12 @@ async def _(
|
|||||||
target: At | Me,
|
target: At | Me,
|
||||||
event_session: EventSession,
|
event_session: EventSession,
|
||||||
):
|
):
|
||||||
|
async with trigger(
|
||||||
|
session_persist_id=await get_session_persist_id(event_session),
|
||||||
|
game_platform=GAME_TYPE,
|
||||||
|
command_type='bind',
|
||||||
|
command_args=[],
|
||||||
|
):
|
||||||
async with get_session() as session:
|
async with get_session() as session:
|
||||||
bind = await query_bind_info(
|
bind = await query_bind_info(
|
||||||
session=session,
|
session=session,
|
||||||
@@ -50,7 +57,13 @@ async def _(
|
|||||||
|
|
||||||
|
|
||||||
@alc.assign('TETRIO.record.sprint')
|
@alc.assign('TETRIO.record.sprint')
|
||||||
async def _(account: Player):
|
async def _(account: Player, event_session: EventSession):
|
||||||
|
async with trigger(
|
||||||
|
session_persist_id=await get_session_persist_id(event_session),
|
||||||
|
game_platform=GAME_TYPE,
|
||||||
|
command_type='bind',
|
||||||
|
command_args=[],
|
||||||
|
):
|
||||||
await UniMessage.image(raw=await make_sprint_image(account)).finish()
|
await UniMessage.image(raw=await make_sprint_image(account)).finish()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user