Skip to content

Commit

Permalink
replace session with uninfo
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetWq committed Oct 11, 2024
1 parent 624d4db commit 3fa2210
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
18 changes: 10 additions & 8 deletions nonebot_plugin_handle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from nonebot import on_regex, require
from nonebot.log import logger
from nonebot.matcher import Matcher
from nonebot.params import EventToMe, RegexDict
from nonebot.params import Depends, EventToMe, RegexDict
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
from nonebot.utils import run_sync

require("nonebot_plugin_alconna")
require("nonebot_plugin_session")
require("nonebot_plugin_uninfo")

from nonebot_plugin_alconna import (
AlcMatches,
Expand All @@ -24,7 +24,7 @@
on_alconna,
store_true,
)
from nonebot_plugin_session import SessionId, SessionIdType
from nonebot_plugin_uninfo import Uninfo

from .config import Config, handle_config
from .data_source import GuessResult, Handle
Expand All @@ -49,18 +49,20 @@
homepage="https://github.com/noneplugin/nonebot-plugin-handle",
config=Config,
supported_adapters=inherit_supported_adapters(
"nonebot_plugin_alconna", "nonebot_plugin_session"
"nonebot_plugin_alconna", "nonebot_plugin_uninfo"
),
extra={
"example": "猜成语",
},
)


games: dict[str, Handle] = {}
timers: dict[str, TimerHandle] = {}

UserId = Annotated[str, SessionId(SessionIdType.GROUP)]

def get_user_id(uninfo: Uninfo) -> str:
return f"{uninfo.scope}_{uninfo.self_id}_{uninfo.scene_path}"


UserId = Annotated[str, Depends(get_user_id)]


def game_is_running(user_id: UserId) -> bool:
Expand Down
34 changes: 9 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/noneplugin/nonebot-plugin-handle"
python = "^3.9"
nonebot2 = "^2.3.0"
nonebot-plugin-alconna = ">=0.46.3,<1.0.0"
nonebot-plugin-session = "^0.3.0"
nonebot-plugin-uninfo = ">=0.4.0,<1.0.0"
Pillow = "^10.0.0"
pypinyin = ">=0.40.0,<1.0.0"

Expand Down

0 comments on commit 3fa2210

Please sign in to comment.