Merge branch 'dev' into plugins

This commit is contained in:
镀铬酸钾
2026-01-02 17:45:39 +08:00
committed by GitHub
27 changed files with 1048 additions and 338 deletions

42
plugins/forward_test.py Normal file
View File

@@ -0,0 +1,42 @@
"""
合并转发消息测试插件
"""
from core.command_manager import matcher
from core.bot import Bot
from models import MessageEvent
from models.message import MessageSegment
__plugin_meta__ = {
"name": "furry",
"description": "处理 /furry 指令发送furry图片同时也是bot.build_forward_node演示",
"usage": "/furry - 发送一条furry图",
}
@matcher.command("furry")
async def handle_forward_test(bot: Bot, event: MessageEvent, args: list[str]):
"""
处理 /furry 指令发送furry图片同时也是bot.build_forward_node实例
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数
"""
# 1. 构建消息节点列表
nodes = [
bot.build_forward_node(user_id=event.self_id, nickname="机器人", message="你要的furry来了"),
bot.build_forward_node(user_id=event.user_id, nickname=event.sender.nickname, message="让我看看"),
bot.build_forward_node(
user_id=event.self_id,
nickname="机器人",
message=[
MessageSegment.text("你要的福瑞图"),
MessageSegment.image("https://api.furry.ist/furry-img/")
]
)
]
try:
# 2. 发送合并转发消息
await bot.send_forwarded_messages(event, nodes)
except Exception as e:
await event.reply(f"发送失败: {e}")

View File

@@ -1,3 +1,8 @@
"""
今日人品插件
提供 /jrcd 和 /bbcd 指令,用于娱乐。
"""
import random
from datetime import datetime
@@ -25,7 +30,7 @@ JRCDMSG_2 = [
JRCDMSG_3 = [
"今天的长度是%scm哦豁听说你很勇哦(✧◡✧)",
"今天的长度是%scm嘶哈嘶哈(((o(*°▽°*)o)))...",
"今天的长度是%scm我靠让哥哥爽一爽吧(((o(*°▽°*)o)))...",
"今天的长度是%scm我靠让哥哥爽一-爽吧!(((o(*°▽°*)o)))...",
"今天的长度是%scm单是看到哥哥的长度就....(〃w〃)",
]
@@ -44,6 +49,12 @@ BBCDMSG7 = ["试试刺刀看看谁能赢吧!"]
def get_jrcd(user_id: int) -> int:
"""
根据用户ID和当前日期生成一个伪随机的“长度”值。
:param user_id: 用户QQ号。
:return: 返回一个1到30之间的整数。
"""
current_time = (
datetime.now().year * 100 + datetime.now().month * 100 + datetime.now().day
)
@@ -58,11 +69,11 @@ def get_jrcd(user_id: int) -> int:
@matcher.command("jrcd")
async def handle_jrcd(bot: Bot, event: MessageEvent, args: list[str]):
"""
处理 jrcd 指令,来看看你的长度吧!
处理 jrcd 指令,回复用户的“今日长度”。
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数列表
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数列表(未使用)。
"""
user_id = event.user_id
jrcd = get_jrcd(user_id)
@@ -79,11 +90,11 @@ async def handle_jrcd(bot: Bot, event: MessageEvent, args: list[str]):
@matcher.command("bbcd")
async def handle_bbcd(bot: Bot, event: MessageEvent, args: list[str]):
"""
处理 bbcd 指令,和别人比比长度吧!
处理 bbcd 指令,比较两位用户的“长度”。
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数列表
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数列表(未使用)。
"""
message = event.message
print(message)

View File

@@ -18,4 +18,11 @@ __plugin_meta__ = {
@matcher.command("thpic")
async def handle_echo(bot: Bot, event: MessageEvent, args: list[str]):
"""
处理 thpic 指令发送一张随机的东方Project图片。
:param bot: Bot 实例(未使用)。
:param event: 消息事件对象。
:param args: 指令参数列表(未使用)。
"""
await event.reply(MessageSegment.image("https://img.paulzzh.com/touhou/random"))