Skip to content

Commit 165eb09

Browse files
适配Amrita1.x
1 parent 0176364 commit 165eb09

6 files changed

Lines changed: 345 additions & 249 deletions

File tree

=0.7.3

Whitespace-only changes.

amrita_plugin_omikuji/llm_tool.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import typing
22

3-
from amrita.plugins.chat.API import (
3+
from amrita.plugins.chat.runtime import AmritaChatObject
4+
from amrita_core import (
45
ToolContext,
56
on_tools,
67
)
@@ -36,13 +37,14 @@ def format_omikuji(data: OmikujiData, user_name: str | None = ""):
3637
@on_tools(FUNC_DEFINTION, custom_run=True, strict=True)
3738
async def omikuji(ctx: ToolContext) -> str:
3839
logger.info("获取御神签")
39-
nb_event: MessageEvent = typing.cast(MessageEvent, ctx.event.get_nonebot_event())
40+
obj: AmritaChatObject = typing.cast(AmritaChatObject, ctx.event.chat_object)
41+
nb_event: MessageEvent = obj.event
4042
is_group = hasattr(nb_event, "group_id")
41-
bot = get_bot(str(ctx.event._nbevent.self_id))
43+
bot = get_bot(str(nb_event.self_id))
4244

4345
if (data := await get_cached_omikuji(nb_event)) is None:
4446
await bot.send(
45-
ctx.event._nbevent,
47+
nb_event,
4648
"轻轻摇动古老的签筒,竹签哗啦作响... 心中默念所求之事... 一支签缓缓落下。",
4749
)
4850
data = await generate_omikuji(ctx.data["theme"], is_group)

amrita_plugin_omikuji/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import random
44
from typing import Literal
55

6-
from amrita.plugins.chat.API import (
6+
from amrita_core import (
77
FunctionDefinitionSchema,
88
FunctionParametersSchema,
99
FunctionPropertySchema,

amrita_plugin_omikuji/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from copy import deepcopy
44
from datetime import datetime, timedelta
55

6-
from amrita.plugins.chat.API import (
6+
from amrita.plugins.chat.config import (
77
config_manager,
8-
tools_caller,
98
)
10-
from amrita.plugins.chat.utils.models import Message
9+
from amrita_core.libchat import tools_caller
10+
from amrita_core.types import Message
1111
from nonebot import logger
1212

1313
from .cache import OmikujiCacheData

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "amrita-plugin-omikuji"
3-
version = "0.1.2.post1"
3+
version = "0.1.3"
44
description = "AmritaBot的御神签插件"
55
readme = "README.md"
66
requires-python = ">=3.10, <4.0"
@@ -10,7 +10,7 @@ dependencies = [
1010
"nonebot-plugin-localstore>=0.7.4",
1111
"aiofiles>=24.1.0",
1212
"nonebot-plugin-orm>=0.8.2",
13-
"amrita[full]>=0.7.3",
13+
"amrita[full]>=1.0.1",
1414
"zipp>=3.23.0",
1515
]
1616
license = "GPL-3.0-or-later"

0 commit comments

Comments
 (0)