mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12a934566d | |||
| ff71dba516 | |||
| e029d51494 | |||
|
|
b1f48da6fe | ||
| 9a2927542a |
@@ -1,3 +1 @@
|
|||||||
BIND_COMMAND: list[str] = ['绑定', 'bind']
|
|
||||||
QUERY_COMMAND: list[str] = ['查', '查询', 'query', 'stats']
|
|
||||||
CANT_VERIFY_MESSAGE = '* 由于无法验证绑定信息, 不能保证查询到的用户为本人\n'
|
CANT_VERIFY_MESSAGE = '* 由于无法验证绑定信息, 不能保证查询到的用户为本人\n'
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ from playwright.async_api import TimeoutError, ViewportSize
|
|||||||
from ..config.config import Config
|
from ..config.config import Config
|
||||||
from .browser import BrowserManager
|
from .browser import BrowserManager
|
||||||
from .retry import retry
|
from .retry import retry
|
||||||
|
from .time_it import time_it
|
||||||
|
|
||||||
config = get_plugin_config(Config)
|
config = get_plugin_config(Config)
|
||||||
|
|
||||||
|
|
||||||
@retry(exception_type=TimeoutError, reply='截图失败, 重试中')
|
@retry(exception_type=TimeoutError, reply='截图失败, 重试中')
|
||||||
|
@time_it
|
||||||
async def screenshot(url: str) -> bytes:
|
async def screenshot(url: str) -> bytes:
|
||||||
browser = await BrowserManager.get_browser()
|
browser = await BrowserManager.get_browser()
|
||||||
async with (
|
async with (
|
||||||
|
|||||||
21
nonebot_plugin_tetris_stats/utils/time_it.py
Normal file
21
nonebot_plugin_tetris_stats/utils/time_it.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from collections.abc import Callable, Coroutine
|
||||||
|
from functools import wraps
|
||||||
|
from time import time_ns
|
||||||
|
from typing import Any, ParamSpec, TypeVar
|
||||||
|
|
||||||
|
from nonebot.log import logger
|
||||||
|
|
||||||
|
T = TypeVar('T')
|
||||||
|
P = ParamSpec('P')
|
||||||
|
|
||||||
|
|
||||||
|
def time_it(func: Callable[P, Coroutine[Any, Any, T]]) -> Callable[P, Coroutine[Any, Any, T]]:
|
||||||
|
@wraps(func)
|
||||||
|
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
|
||||||
|
start = time_ns()
|
||||||
|
try:
|
||||||
|
return await func(*args, **kwargs)
|
||||||
|
finally:
|
||||||
|
logger.debug(f'{func.__name__} took {(time_ns() - start) / 1e6}ms')
|
||||||
|
|
||||||
|
return wrapper
|
||||||
18
poetry.lock
generated
18
poetry.lock
generated
@@ -285,13 +285,13 @@ full = ["arclet-alconna-tools (>=0.2.0)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arclet-alconna-tools"
|
name = "arclet-alconna-tools"
|
||||||
version = "0.7.8"
|
version = "0.7.9"
|
||||||
description = "Builtin Tools for Alconna"
|
description = "Builtin Tools for Alconna"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "arclet_alconna_tools-0.7.8-py3-none-any.whl", hash = "sha256:be57595d0f07882e1b221dacff0a81d492643915b85219d1b1e7ba5bee034c36"},
|
{file = "arclet_alconna_tools-0.7.9-py3-none-any.whl", hash = "sha256:01a3462bb9f8dbe55010b394f7a0ac11e331799d463e326738870dce191aa608"},
|
||||||
{file = "arclet_alconna_tools-0.7.8.tar.gz", hash = "sha256:4c54944bc4e495e730f41f96f1af23b86f3c8cde6c332699a9d82f839790ad32"},
|
{file = "arclet_alconna_tools-0.7.9.tar.gz", hash = "sha256:bded24c4157e13e2d803fe7b77ee246fda456206451337015513f150d1e4449c"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@@ -1721,23 +1721,23 @@ nonebot2 = ">=2.3.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-plugin-alconna"
|
name = "nonebot-plugin-alconna"
|
||||||
version = "0.50.3"
|
version = "0.51.0"
|
||||||
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.50.3-py3-none-any.whl", hash = "sha256:4c8e2f8615eb984706f292e3ec9b9e0af904aeaf25a96c888b77851a3a2685c5"},
|
{file = "nonebot_plugin_alconna-0.51.0-py3-none-any.whl", hash = "sha256:0889f2a16824fe9e07adca6d2c1197db989208ace20f70f59829b6dec0f67b7e"},
|
||||||
{file = "nonebot_plugin_alconna-0.50.3.tar.gz", hash = "sha256:f29428dbea17420e34625f21bd806e7c12b0f383e4f972d3ce42aa09d5c84e97"},
|
{file = "nonebot_plugin_alconna-0.51.0.tar.gz", hash = "sha256:cf4c8f0d638e547993cb1ef13ccd2d5fa968206f83f1e7fc281dc359a497e8a1"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
arclet-alconna = ">=1.8.21"
|
arclet-alconna = ">=1.8.23"
|
||||||
arclet-alconna-tools = ">=0.7.8"
|
arclet-alconna-tools = ">=0.7.9"
|
||||||
importlib-metadata = ">=4.13.0"
|
importlib-metadata = ">=4.13.0"
|
||||||
nepattern = ">=0.7.4"
|
nepattern = ">=0.7.4"
|
||||||
nonebot-plugin-waiter = ">=0.6.0"
|
nonebot-plugin-waiter = ">=0.6.0"
|
||||||
nonebot2 = ">=2.3.0"
|
nonebot2 = ">=2.3.0"
|
||||||
tarina = ">=0.5.4"
|
tarina = ">=0.5.5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-plugin-apscheduler"
|
name = "nonebot-plugin-apscheduler"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = 'nonebot-plugin-tetris-stats'
|
name = 'nonebot-plugin-tetris-stats'
|
||||||
version = '1.4.4'
|
version = '1.4.5'
|
||||||
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
|
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
|
||||||
authors = ['scdhh <wallfjjd@gmail.com>']
|
authors = ['scdhh <wallfjjd@gmail.com>']
|
||||||
readme = 'README.md'
|
readme = 'README.md'
|
||||||
@@ -130,4 +130,3 @@ quote-style = 'single'
|
|||||||
|
|
||||||
[tool.nonebot]
|
[tool.nonebot]
|
||||||
plugins = ['nonebot_plugin_tetris_stats']
|
plugins = ['nonebot_plugin_tetris_stats']
|
||||||
# plugins = ['test_datetime']
|
|
||||||
|
|||||||
Reference in New Issue
Block a user