Skip to content

Commit a510ddd

Browse files
authored
Merge pull request #1249 from MaiM-with-u/dev
Dev
2 parents 0e0179f + 6dfc455 commit a510ddd

110 files changed

Lines changed: 5874 additions & 3867 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
**🍔MaiCore 是一个基于大语言模型的可交互智能体**
2727

2828
- 💭 **智能对话系统**:基于 LLM 的自然语言交互,聊天时机控制。
29-
- 🔌 **强大插件系统**:全面重构的插件架构,更多API。
3029
- 🤔 **实时思维系统**:模拟人类思考过程。
3130
- 🧠 **表达学习功能**:学习群友的说话风格和表达方式
3231
- 💝 **情感表达系统**:情绪系统和表情包系统。
33-
- 🧠 **持久记忆系统**:基于图的长期记忆存储。
34-
- 🔄 **动态人格系统**:自适应的性格特征和表达方式。
32+
- 🔌 **强大插件系统**:提供API和事件系统,可编写强大插件。
3533

3634
<div style="text-align: center">
3735
<a href="https://www.bilibili.com/video/BV1amAneGE3P" target="_blank">
@@ -46,7 +44,7 @@
4644

4745
## 🔥 更新和安装
4846

49-
**最新版本: v0.10.2** ([更新日志](changelogs/changelog.md))
47+
**最新版本: v0.10.3** ([更新日志](changelogs/changelog.md))
5048

5149
可前往 [Release](https://github.com/MaiM-with-u/MaiBot/releases/) 页面下载最新版本
5250
可前往 [启动器发布页面](https://github.com/MaiM-with-u/mailauncher/releases/)下载最新启动器
@@ -64,21 +62,21 @@
6462
> - QQ 机器人存在被限制风险,请自行了解,谨慎使用。
6563
> - 由于程序处于开发中,可能消耗较多 token。
6664
67-
## 麦麦MC项目(早期开发)
65+
## 麦麦MC项目MaiCraft(早期开发)
6866
[让麦麦玩MC](https://github.com/MaiM-with-u/Maicraft)
6967

7068
交流群:1058573197
7169

7270
## 💬 讨论
7371

7472
**技术交流群:**
75-
- [一群](https://qm.qq.com/q/VQ3XZrWgMs) |
76-
[二群](https://qm.qq.com/q/RzmCiRtHEW) |
77-
[三群](https://qm.qq.com/q/wlH5eT8OmQ) |
78-
[四群](https://qm.qq.com/q/wGePTl1UyY)
73+
[麦麦脑电图](https://qm.qq.com/q/RzmCiRtHEW) |
74+
[麦麦脑磁图](https://qm.qq.com/q/wlH5eT8OmQ) |
75+
[麦麦大脑磁共振](https://qm.qq.com/q/VQ3XZrWgMs) |
76+
[麦麦要当VTB](https://qm.qq.com/q/wGePTl1UyY)
7977

8078
**聊天吹水群:**
81-
- [五群](https://qm.qq.com/q/JxvHZnxyec)
79+
- [麦麦之闲聊群](https://qm.qq.com/q/JxvHZnxyec)
8280

8381
**插件开发测试版群:**
8482
- [插件开发群](https://qm.qq.com/q/1036092828)

bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ def easter_egg():
6262
async def graceful_shutdown(): # sourcery skip: use-named-expression
6363
try:
6464
logger.info("正在优雅关闭麦麦...")
65-
65+
6666
from src.plugin_system.core.events_manager import events_manager
6767
from src.plugin_system.base.component_types import EventType
68+
6869
# 触发 ON_STOP 事件
6970
await events_manager.handle_mai_events(event_type=EventType.ON_STOP)
7071

changelogs/changelog.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
# Changelog
22

3-
0.10.3饼:
4-
重名问题
5-
动态频率进一步优化
3+
0.10.4饼 表达方式优化
4+
无了
5+
6+
## [0.10.3] - 2025-9-22
7+
### 🌟 主要功能更改
8+
- planner支持多动作,移除Sub_planner
9+
- 移除激活度系统,现在回复完全由planner控制
10+
- 现可自定义planner行为,更优化的聊天频率控制
11+
- 支持发送转发和合并转发
12+
- 关系现在支持多人的信息
13+
- 更好的event系统,正式建立
14+
15+
### 细节功能更改
16+
- 支持所有表达方式互通
17+
- 现可使用付费嵌入模型
18+
- 添加多种发送类型
19+
- 优化识图token限制
20+
- 为空回复添加重试机制
21+
- 加入brainchat模式,为私聊支持做准备
22+
- 修复qq号格式
23+
624

725

826
## [0.10.2] - 2025-8-31

plugins/hello_world_plugin/plugin.py

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import random
12
from typing import List, Tuple, Type, Any
23
from src.plugin_system import (
34
BasePlugin,
@@ -12,7 +13,10 @@
1213
EventType,
1314
MaiMessages,
1415
ToolParamType,
16+
ReplyContentType,
17+
emoji_api,
1518
)
19+
from src.config.config import global_config
1620

1721

1822
class CompareNumbersTool(BaseTool):
@@ -24,6 +28,7 @@ class CompareNumbersTool(BaseTool):
2428
("num1", ToolParamType.FLOAT, "第一个数字", True, None),
2529
("num2", ToolParamType.FLOAT, "第二个数字", True, None),
2630
]
31+
available_for_llm = True
2732

2833
async def execute(self, function_args: dict[str, Any]) -> dict[str, Any]:
2934
"""执行比较两个数的大小
@@ -136,12 +141,80 @@ class PrintMessage(BaseEventHandler):
136141
handler_name = "print_message_handler"
137142
handler_description = "打印接收到的消息"
138143

139-
async def execute(self, message: MaiMessages | None) -> Tuple[bool, bool, str | None, None]:
144+
async def execute(self, message: MaiMessages | None) -> Tuple[bool, bool, str | None, None, None]:
140145
"""执行打印消息事件处理"""
141146
# 打印接收到的消息
142147
if self.get_config("print_message.enabled", False):
143148
print(f"接收到消息: {message.raw_message if message else '无效消息'}")
144-
return True, True, "消息已打印", None
149+
return True, True, "消息已打印", None, None
150+
151+
152+
class ForwardMessages(BaseEventHandler):
153+
"""
154+
把接收到的消息转发到指定聊天ID
155+
156+
此组件是HYBRID消息和FORWARD消息的使用示例。
157+
每收到10条消息,就会以1%的概率使用HYBRID消息转发,否则使用FORWARD消息转发。
158+
"""
159+
160+
event_type = EventType.ON_MESSAGE
161+
handler_name = "forward_messages_handler"
162+
handler_description = "把接收到的消息转发到指定聊天ID"
163+
164+
def __init__(self, *args, **kwargs):
165+
super().__init__(*args, **kwargs)
166+
self.counter = 0 # 用于计数转发的消息数量
167+
self.messages: List[str] = []
168+
169+
async def execute(self, message: MaiMessages | None) -> Tuple[bool, bool, None, None, None]:
170+
if not message:
171+
return True, True, None, None, None
172+
stream_id = message.stream_id or ""
173+
174+
if message.plain_text:
175+
self.messages.append(message.plain_text)
176+
self.counter += 1
177+
if self.counter % 10 == 0:
178+
if random.random() < 0.01:
179+
success = await self.send_hybrid(stream_id, [(ReplyContentType.TEXT, msg) for msg in self.messages])
180+
else:
181+
success = await self.send_forward(
182+
stream_id,
183+
[
184+
(
185+
str(global_config.bot.qq_account),
186+
str(global_config.bot.nickname),
187+
[(ReplyContentType.TEXT, msg)],
188+
)
189+
for msg in self.messages
190+
],
191+
)
192+
if not success:
193+
raise ValueError("转发消息失败")
194+
self.messages = []
195+
return True, True, None, None, None
196+
197+
198+
class RandomEmojis(BaseCommand):
199+
command_name = "random_emojis"
200+
command_description = "发送多张随机表情包"
201+
command_pattern = r"^/random_emojis$"
202+
203+
async def execute(self):
204+
emojis = await emoji_api.get_random(5)
205+
if not emojis:
206+
return False, "未找到表情包", False
207+
emoji_base64_list = []
208+
for emoji in emojis:
209+
emoji_base64_list.append(emoji[0])
210+
return await self.forward_images(emoji_base64_list)
211+
212+
async def forward_images(self, images: List[str]):
213+
"""
214+
把多张图片用合并转发的方式发给用户
215+
"""
216+
success = await self.send_forward([("0", "神秘用户", [(ReplyContentType.IMAGE, img)]) for img in images])
217+
return (True, "已发送随机表情包", True) if success else (False, "发送随机表情包失败", False)
145218

146219

147220
# ===== 插件注册 =====
@@ -153,7 +226,7 @@ class HelloWorldPlugin(BasePlugin):
153226

154227
# 插件基本信息
155228
plugin_name: str = "hello_world_plugin" # 内部标识符
156-
enable_plugin: bool = True
229+
enable_plugin: bool = False
157230
dependencies: List[str] = [] # 插件依赖列表
158231
python_dependencies: List[str] = [] # Python包依赖列表
159232
config_file_name: str = "config.toml" # 配置文件名
@@ -185,6 +258,8 @@ def get_plugin_components(self) -> List[Tuple[ComponentInfo, Type]]:
185258
(ByeAction.get_action_info(), ByeAction), # 添加告别Action
186259
(TimeCommand.get_command_info(), TimeCommand),
187260
(PrintMessage.get_handler_info(), PrintMessage),
261+
(ForwardMessages.get_handler_info(), ForwardMessages),
262+
(RandomEmojis.get_command_info(), RandomEmojis),
188263
]
189264

190265

0 commit comments

Comments
 (0)