1
0
forked from bot/app

添加对主流框架的消息io支持

This commit is contained in:
2024-08-20 06:20:41 +08:00
parent 237789e0d4
commit 0c942d9806
26 changed files with 267 additions and 192 deletions

View File

@ -1,8 +1,8 @@
from nonebot.plugin import PluginMetadata
from liteyuki import get_bot
from .crt_matchers import * # type_: ignore
from .rt_guide import * # type_: ignore
from .crt_matchers import * # type: ignore
from .rt_guide import * # type: ignore
__plugin_meta__ = PluginMetadata(

View File

@ -339,7 +339,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
await md.send_md(f"{info}\n\n" f"```\n{log}\n```", bot, event=event)
elif sc.get("uninstall") and perm_s:
plugin_name: str = result.subcommands["uninstall"].args.get("plugin_name") # type_: ignore
plugin_name: str = result.subcommands["uninstall"].args.get("plugin_name") # type: ignore
found_installed_plugin: InstalledPlugin = plugin_db.where_one(
InstalledPlugin(), "module_name = ?", plugin_name
)

View File

@ -69,6 +69,8 @@ async def get_stat_msg_image(
condition,
*condition_args
)
if not msg_rows:
msg_rows = []
timestamps = []
msg_count = []
msg_rows.sort(key=lambda x: x.time)

View File

@ -98,8 +98,10 @@ async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
bot_id = result.other_args.get("bot_id")
user_id = result.other_args.get("user_id")
if group_id in ["current", "c"]:
if group_id in ["current", "c"] and hasattr(event, "group_id"):
group_id = str(event_utils.get_group_id(event))
else:
group_id = "all"
if group_id in ["all", "a"]:
group_id = "all"

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/20 上午5:10
@Author : snowykami
@Email : snowykami@outlook.com
@File : to_liteyuki.py
@Software: PyCharm
"""
from nonebot import Bot, get_bot, on_message
from nonebot.plugin import PluginMetadata
from nonebot.adapters.onebot.v11 import MessageEvent, Bot
from liteyuki.comm.storage import shared_memory
from liteyuki.message.event import Event
__plugin_meta__ = PluginMetadata(
name="轻雪物流",
description="把消息事件传递给轻雪",
usage="无需使用",
)
@on_message().handle()
async def _(bot: Bot, event: MessageEvent):
liteyuki_event = Event(
type=event.message_type,
data=event.dict(),
bot_id=bot.self_id,
session_id=str(event.user_id if event.message_type == "private" else event.group_id),
session_type=event.message_type,
receive_channel="event_to_nonebot"
)
shared_memory.publish("event_to_liteyuki", liteyuki_event)
@shared_memory.on_subscriber_receive("event_to_nonebot")
async def _(event: Event):
bot: Bot = get_bot(event.bot_id)
await bot.send_msg(message_type=event.type, user_id=int(event.session_id), group_id=int(event.session_id), message=event.data["message"])