fix: 不正确的事件
This commit is contained in:
+35
-9
@@ -1,15 +1,41 @@
|
||||
from astrbot.api.event import AstrMessageEvent
|
||||
from astrbot.api.provider import LLMResponse
|
||||
from astrbot.api import logger
|
||||
from astrbot.core.message.message_event_result import MessageChain
|
||||
from astrbot.core.message.message_event_result import MessageChain,Plain
|
||||
from ..tool.pattern import Pattern
|
||||
from astrbot.api.star import Star
|
||||
import asyncio
|
||||
|
||||
# 解析模板并进行定时
|
||||
async def timer(event:AstrMessageEvent,req:LLMResponse):
|
||||
if not req.role == 'assistant':
|
||||
return
|
||||
class TimerService:
|
||||
def __init__(self,star:Star) -> None:
|
||||
self.star = star
|
||||
pass
|
||||
|
||||
logger.info("[wait_msg]:开始解析模板")
|
||||
llm_res = req.completion_text
|
||||
dump = Pattern(llm_res)
|
||||
await event.send(MessageChain().message("awa定时时间消息:{0}过滤后:{1}".format(dump.count,dump.string)))
|
||||
# 解析模板并进行定时
|
||||
async def parse(self,event:AstrMessageEvent):
|
||||
res = event.get_result()
|
||||
if not res:
|
||||
return
|
||||
|
||||
Second:int|None = None
|
||||
logger.info("[wait_msg]:开始解析模板")
|
||||
|
||||
chain = res.chain
|
||||
for i in chain :
|
||||
if not isinstance(i,Plain):
|
||||
continue
|
||||
dump = Pattern(i.text)
|
||||
i.text = dump.string
|
||||
Second = dump.count
|
||||
if not Second is None:
|
||||
self.timer(event,Second)
|
||||
|
||||
yield
|
||||
|
||||
# 定时:
|
||||
def timer(self,event:AstrMessageEvent,Sec:int):
|
||||
asyncio.create_task(self.timer_task())
|
||||
|
||||
async def timer_task(self):
|
||||
await asyncio.sleep(1)
|
||||
logger.warning("awa现在过去一秒了哦")
|
||||
Reference in New Issue
Block a user