Merge remote-tracking branch 'origin/main-fix' into main-fix
This commit is contained in:
12
.github/workflows/docker-image.yml
vendored
12
.github/workflows/docker-image.yml
vendored
@@ -22,18 +22,18 @@ jobs:
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Determine Image Tags
|
||||
id: tags
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }},${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
|
||||
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }},${{ vars.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
|
||||
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main,${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
|
||||
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:main,${{ vars.DOCKERHUB_USERNAME }}/maimbot:latest" >> $GITHUB_OUTPUT
|
||||
elif [ "${{ github.ref }}" == "refs/heads/main-fix" ]; then
|
||||
echo "tags=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:main-fix" >> $GITHUB_OUTPUT
|
||||
echo "tags=${{ vars.DOCKERHUB_USERNAME }}/maimbot:main-fix" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
@@ -44,5 +44,5 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.tags.outputs.tags }}
|
||||
push: true
|
||||
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache
|
||||
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maimbot:buildcache,mode=max
|
||||
cache-from: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/maimbot:buildcache
|
||||
cache-to: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/maimbot:buildcache,mode=max
|
||||
|
||||
18
README.md
18
README.md
@@ -128,11 +128,11 @@
|
||||
MaiMBot是一个开源项目,我们非常欢迎你的参与。你的贡献,无论是提交bug报告、功能需求还是代码pr,都对项目非常宝贵。我们非常感谢你的支持!🎉 但无序的讨论会降低沟通效率,进而影响问题的解决速度,因此在提交任何贡献前,请务必先阅读本项目的[贡献指南](CONTRIBUTE.md)
|
||||
|
||||
### 💬交流群
|
||||
- [一群](https://qm.qq.com/q/VQ3XZrWgMs) 766798517 ,建议加下面的(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [二群](https://qm.qq.com/q/RzmCiRtHEW) 571780722 (开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [三群](https://qm.qq.com/q/wlH5eT8OmQ) 1035228475(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [四群](https://qm.qq.com/q/wlH5eT8OmQ) 729957033(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
|
||||
- [五群](https://qm.qq.com/q/JxvHZnxyec) 1022489779(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [一群](https://qm.qq.com/q/VQ3XZrWgMs) 766798517 【已满】(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [二群](https://qm.qq.com/q/RzmCiRtHEW) 571780722 【已满】(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [三群](https://qm.qq.com/q/wlH5eT8OmQ) 1035228475【已满】(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
- [四群](https://qm.qq.com/q/wlH5eT8OmQ) 729957033【已满】(开发和建议相关讨论)不一定有空回复,会优先写文档和代码
|
||||
|
||||
|
||||
<div align="left">
|
||||
@@ -251,10 +251,12 @@ SengokuCola~~纯编程外行,面向cursor编程,很多代码写得不好多
|
||||
|
||||
感谢各位大佬!
|
||||
|
||||
<a href="https://github.com/SengokuCola/MaiMBot/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=SengokuCola/MaiMBot" />
|
||||
<a href="https://github.com/MaiM-with-u/MaiBot/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=MaiM-with-u/MaiBot" />
|
||||
</a>
|
||||
|
||||
**也感谢每一位给麦麦发展提出宝贵意见与建议的用户,感谢陪伴麦麦走到现在的你们**
|
||||
|
||||
## Stargazers over time
|
||||
|
||||
[](https://starchart.cc/SengokuCola/MaiMBot)
|
||||
[](https://starchart.cc/MaiM-with-u/MaiBot)
|
||||
|
||||
8
bot.py
8
bot.py
@@ -203,6 +203,9 @@ def check_eula():
|
||||
if eula_new_hash == confirmed_content:
|
||||
eula_confirmed = True
|
||||
eula_updated = False
|
||||
if eula_new_hash == os.getenv("EULA_AGREE"):
|
||||
eula_confirmed = True
|
||||
eula_updated = False
|
||||
|
||||
# 检查隐私条款确认文件是否存在
|
||||
if privacy_confirm_file.exists():
|
||||
@@ -211,11 +214,14 @@ def check_eula():
|
||||
if privacy_new_hash == confirmed_content:
|
||||
privacy_confirmed = True
|
||||
privacy_updated = False
|
||||
if privacy_new_hash == os.getenv("PRIVACY_AGREE"):
|
||||
privacy_confirmed = True
|
||||
privacy_updated = False
|
||||
|
||||
# 如果EULA或隐私条款有更新,提示用户重新确认
|
||||
if eula_updated or privacy_updated:
|
||||
print("EULA或隐私条款内容已更新,请在阅读后重新确认,继续运行视为同意更新后的以上两款协议")
|
||||
print('输入"同意"或"confirmed"继续运行')
|
||||
print(f'输入"同意"或"confirmed"或设置环境变量"EULA_AGREE={eula_new_hash}"和"PRIVACY_AGREE={privacy_new_hash}"继续运行')
|
||||
while True:
|
||||
user_input = input().strip().lower()
|
||||
if user_input in ["同意", "confirmed"]:
|
||||
|
||||
@@ -92,9 +92,12 @@ async def _(bot: Bot):
|
||||
|
||||
@msg_in.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
#处理合并转发消息
|
||||
if "forward" in event.message:
|
||||
await chat_bot.handle_forward_message(event , bot)
|
||||
else :
|
||||
await chat_bot.handle_message(event, bot)
|
||||
|
||||
|
||||
@notice_matcher.handle()
|
||||
async def _(bot: Bot, event: NoticeEvent, state: T_State):
|
||||
logger.debug(f"收到通知:{event}")
|
||||
|
||||
@@ -5,6 +5,7 @@ from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
PrivateMessageEvent,
|
||||
GroupMessageEvent,
|
||||
NoticeEvent,
|
||||
PokeNotifyEvent,
|
||||
GroupRecallNoticeEvent,
|
||||
@@ -411,6 +412,69 @@ class ChatBot:
|
||||
|
||||
await self.message_process(message_cq)
|
||||
|
||||
async def handle_forward_message(self, event: MessageEvent, bot: Bot) -> None:
|
||||
"""专用于处理合并转发的消息处理器"""
|
||||
|
||||
# 获取合并转发消息的详细信息
|
||||
forward_info = await bot.get_forward_msg(message_id=event.message_id)
|
||||
messages = forward_info["messages"]
|
||||
|
||||
# 构建合并转发消息的文本表示
|
||||
processed_messages = []
|
||||
for node in messages:
|
||||
# 提取发送者昵称
|
||||
nickname = node["sender"].get("nickname", "未知用户")
|
||||
|
||||
# 处理消息内容
|
||||
message_content = []
|
||||
for seg in node["message"]:
|
||||
if seg["type"] == "text":
|
||||
message_content.append(seg["data"]["text"])
|
||||
elif seg["type"] == "image":
|
||||
message_content.append("[图片]")
|
||||
elif seg["type"] =="face":
|
||||
message_content.append("[表情]")
|
||||
elif seg["type"] == "at":
|
||||
message_content.append(f"@{seg['data'].get('qq', '未知用户')}")
|
||||
else:
|
||||
message_content.append(f"[{seg['type']}]")
|
||||
|
||||
# 拼接为【昵称】+ 内容
|
||||
processed_messages.append(f"【{nickname}】{''.join(message_content)}")
|
||||
|
||||
# 组合所有消息
|
||||
combined_message = "\n".join(processed_messages)
|
||||
combined_message = f"合并转发消息内容:\n{combined_message}"
|
||||
|
||||
# 构建用户信息(使用转发消息的发送者)
|
||||
user_info = UserInfo(
|
||||
user_id=event.user_id,
|
||||
user_nickname=event.sender.nickname,
|
||||
user_cardname=event.sender.card if hasattr(event.sender, "card") else None,
|
||||
platform="qq",
|
||||
)
|
||||
|
||||
# 构建群聊信息(如果是群聊)
|
||||
group_info = None
|
||||
if isinstance(event, GroupMessageEvent):
|
||||
group_info = GroupInfo(
|
||||
group_id=event.group_id,
|
||||
group_name= None,
|
||||
platform="qq"
|
||||
)
|
||||
|
||||
# 创建消息对象
|
||||
message_cq = MessageRecvCQ(
|
||||
message_id=event.message_id,
|
||||
user_info=user_info,
|
||||
raw_message=combined_message,
|
||||
group_info=group_info,
|
||||
reply_message=event.reply,
|
||||
platform="qq",
|
||||
)
|
||||
|
||||
# 进入标准消息处理流程
|
||||
await self.message_process(message_cq)
|
||||
|
||||
# 创建全局ChatBot实例
|
||||
chat_bot = ChatBot()
|
||||
|
||||
Reference in New Issue
Block a user