🐛 hotfix: from mypy import
This commit is contained in:
@ -1,10 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
|
||||
@Time : 2024/8/19 下午10:44
|
||||
@Author : snowykami
|
||||
@Email : snowykami@outlook.com
|
||||
@File : __init__.py.py
|
||||
@Software: PyCharm
|
||||
该模块参考并引用了nonebot-plugin-alconna的消息段定义
|
||||
"""
|
||||
from typing import Any
|
||||
|
||||
from magicoca import Chan, select
|
||||
from mypy.server.objgraph import Iterable
|
||||
from six import Iterator
|
||||
|
||||
|
||||
def message_handler_thread(i_chans: Iterable[Chan[Any]]):
|
||||
"""
|
||||
Args:
|
||||
i_chans: 多路输入管道组
|
||||
Returns:
|
||||
"""
|
||||
for msg in select(*i_chans):
|
||||
print("Recv from anybot", msg)
|
0
liteyuki/session/message/segments.py
Normal file
0
liteyuki/session/message/segments.py
Normal file
51
liteyuki/session/models.py
Normal file
51
liteyuki/session/models.py
Normal file
@ -0,0 +1,51 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class User(BaseModel):
|
||||
"""
|
||||
用户信息
|
||||
Attributes:
|
||||
id: 用户ID
|
||||
name: 用户名
|
||||
nick: 用户昵称
|
||||
avatar: 用户头像图链接
|
||||
"""
|
||||
id: str
|
||||
name: str | None
|
||||
nick: str | None
|
||||
avatar: str | None
|
||||
|
||||
class Scene(BaseModel):
|
||||
"""
|
||||
场景信息
|
||||
Attributes:
|
||||
id: 场景ID
|
||||
type: 场景类型
|
||||
name: 场景名
|
||||
avatar: 场景头像图链接
|
||||
parent: 父场景
|
||||
"""
|
||||
id: str
|
||||
type: str
|
||||
name: str | None
|
||||
avatar: str | None
|
||||
parent: "Scene | None"
|
||||
|
||||
class Session(BaseModel):
|
||||
"""
|
||||
会话信息
|
||||
Attributes:
|
||||
self_id: 机器人ID
|
||||
adapter: 适配器ID
|
||||
scope: 会话范围
|
||||
scene: 场景信息
|
||||
user: 用户信息
|
||||
member: 成员信息,仅频道及群聊有效
|
||||
operator: 操作者信息,仅频道及群聊有效
|
||||
"""
|
||||
self_id: str
|
||||
adapter: str
|
||||
scope: str
|
||||
scene: Scene
|
||||
user: User
|
||||
member: "Member | None"
|
||||
operator: "Member | None"
|
@ -11,8 +11,6 @@ Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
|
||||
from queue import Queue
|
||||
|
||||
from liteyuki.comm.storage import shared_memory
|
||||
from liteyuki.log import logger
|
||||
from liteyuki.session.event import MessageEvent
|
||||
from liteyuki.session.matcher import Matcher
|
||||
from liteyuki.session.rule import Rule, empty_rule
|
||||
@ -20,24 +18,6 @@ from liteyuki.session.rule import Rule, empty_rule
|
||||
_matcher_list: list[Matcher] = []
|
||||
_queue: Queue = Queue()
|
||||
|
||||
|
||||
@shared_memory.on_subscriber_receive("event_to_liteyuki")
|
||||
async def _(event: MessageEvent):
|
||||
print("AA")
|
||||
current_priority = -1
|
||||
for i, matcher in enumerate(_matcher_list):
|
||||
logger.info(f"Running matcher {matcher} for event: {event}")
|
||||
await matcher.run(event)
|
||||
# 同优先级不阻断,不同优先级阻断
|
||||
if current_priority != matcher.priority:
|
||||
current_priority = matcher.priority
|
||||
if matcher.block:
|
||||
break
|
||||
else:
|
||||
logger.info(f"No matcher matched for event: {event}")
|
||||
print("BB")
|
||||
|
||||
|
||||
def add_matcher(matcher: Matcher):
|
||||
for i, m in enumerate(_matcher_list):
|
||||
if m.priority < matcher.priority:
|
||||
|
@ -1,10 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
|
||||
@Time : 2024/8/19 下午10:47
|
||||
@Author : snowykami
|
||||
@Email : snowykami@outlook.com
|
||||
@File : session.py
|
||||
@Software: PyCharm
|
||||
"""
|
Reference in New Issue
Block a user