Merge branch 'main' of https://github.com/SengokuCola/MaiMBot
This commit is contained in:
31
.github/workflows/docker-image.yml
vendored
Normal file
31
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: Docker Build and Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main # 推送到main分支时触发
|
||||||
|
tags:
|
||||||
|
- 'v*' # 推送v开头的tag时触发(例如v1.0.0)
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: . # Docker构建上下文路径
|
||||||
|
file: ./Dockerfile # Dockerfile路径
|
||||||
|
tags: |
|
||||||
|
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:${{ github.ref_name }}
|
||||||
|
${{ secrets.DOCKERHUB_USERNAME }}/maimbot:latest
|
||||||
|
push: true
|
||||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
FROM nonebot/nb-cli:latest
|
||||||
|
WORKDIR /
|
||||||
|
RUN apt update && apt install -y git
|
||||||
|
RUN git clone https://github.com/SengokuCola/MaiMBot
|
||||||
|
WORKDIR /MaiMBot
|
||||||
|
RUN mkdir config
|
||||||
|
RUN mv /MaiMBot/env.example /MaiMBot/config/.env \
|
||||||
|
&& mv /MaiMBot/src/plugins/chat/bot_config_toml /MaiMBot/config/bot_config.toml
|
||||||
|
RUN ln -s /MaiMBot/config/.env /MaiMBot/.env \
|
||||||
|
&& ln -s /MaiMBot/config/bot_config.toml /MaiMBot/src/plugins/chat/bot_config.toml
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
VOLUME [ "/MaiMBot/config" ]
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT [ "nb","run" ]
|
||||||
11
README.md
11
README.md
@@ -31,6 +31,17 @@
|
|||||||
|
|
||||||
### 安装方法(还没测试好,现在部署可能遇到未知问题!!!!)
|
### 安装方法(还没测试好,现在部署可能遇到未知问题!!!!)
|
||||||
|
|
||||||
|
#### Linux 使用 Docker Compose 部署
|
||||||
|
获取项目根目录中的```docker-compose.yml```文件,运行以下命令
|
||||||
|
```bash
|
||||||
|
NAPCAT_UID=$(id -u) NAPCAT_GID=$(id -g) docker compose up -d
|
||||||
|
```
|
||||||
|
配置文件修改完成后,运行以下命令
|
||||||
|
```bash
|
||||||
|
NAPCAT_UID=$(id -u) NAPCAT_GID=$(id -g) docker compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 手动运行
|
||||||
1. **创建Python环境**
|
1. **创建Python环境**
|
||||||
推荐使用conda或其他环境管理来管理你的python环境
|
推荐使用conda或其他环境管理来管理你的python环境
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
50
docker-compose.yml
Normal file
50
docker-compose.yml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
services:
|
||||||
|
napcat:
|
||||||
|
container_name: napcat
|
||||||
|
environment:
|
||||||
|
- tz=Asia/Shanghai
|
||||||
|
- NAPCAT_UID=${NAPCAT_UID}
|
||||||
|
- NAPCAT_GID=${NAPCAT_GID}
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
- 3001:3001
|
||||||
|
- 6099:6099
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- napcatQQ:/app/.config/QQ
|
||||||
|
- napcatCONFIG:/app/napcat/config
|
||||||
|
image: mlikiowa/napcat-docker:latest
|
||||||
|
|
||||||
|
mongodb:
|
||||||
|
container_name: mongodb
|
||||||
|
environment:
|
||||||
|
- tz=Asia/Shanghai
|
||||||
|
expose:
|
||||||
|
- "27017"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- mongodb:/data/db
|
||||||
|
- mongodbCONFIG:/data/configdb
|
||||||
|
image: mongo:latest
|
||||||
|
|
||||||
|
maimbot:
|
||||||
|
container_name: maimbot
|
||||||
|
environment:
|
||||||
|
- tz=Asia/Shanghai
|
||||||
|
expose:
|
||||||
|
- "8080:8080"
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- mongodb
|
||||||
|
- napcat
|
||||||
|
volumes:
|
||||||
|
- maimbotCONFIG:/MaiMBot/config
|
||||||
|
image: jiajiu/maimbot:latest
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
maimbotCONFIG:
|
||||||
|
napcatQQ:
|
||||||
|
napcatCONFIG:
|
||||||
|
mongodb:
|
||||||
|
mongodbCONFIG:
|
||||||
@@ -2,13 +2,15 @@ from typing import Union, List, Optional, Deque, Dict
|
|||||||
from nonebot.adapters.onebot.v11 import Bot, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, MessageSegment
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
|
import os
|
||||||
from .message import Message, Message_Thinking, MessageSet
|
from .message import Message, Message_Thinking, MessageSet
|
||||||
from .cq_code import CQCode
|
from .cq_code import CQCode
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import time
|
import time
|
||||||
from .storage import MessageStorage
|
from .storage import MessageStorage
|
||||||
from .config import global_config
|
from .config import global_config
|
||||||
from .message_visualizer import message_visualizer
|
if os.name == "nt":
|
||||||
|
from .message_visualizer import message_visualizer
|
||||||
|
|
||||||
|
|
||||||
class SendTemp:
|
class SendTemp:
|
||||||
@@ -161,7 +163,10 @@ class MessageSendControl:
|
|||||||
self._paused = False
|
self._paused = False
|
||||||
self._current_bot = None
|
self._current_bot = None
|
||||||
self.storage = MessageStorage() # 添加存储实例
|
self.storage = MessageStorage() # 添加存储实例
|
||||||
message_visualizer.start()
|
try:
|
||||||
|
message_visualizer.start()
|
||||||
|
except(NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
def set_bot(self, bot: Bot):
|
def set_bot(self, bot: Bot):
|
||||||
"""设置当前bot实例"""
|
"""设置当前bot实例"""
|
||||||
@@ -222,7 +227,10 @@ class MessageSendControl:
|
|||||||
|
|
||||||
# 并行处理所有群组的消息
|
# 并行处理所有群组的消息
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
message_visualizer.update_content(self.send_temp_container)
|
try:
|
||||||
|
message_visualizer.update_content(self.send_temp_container)
|
||||||
|
except(NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
def set_typing_speed(self, min_speed: float, max_speed: float):
|
def set_typing_speed(self, min_speed: float, max_speed: float):
|
||||||
"""设置打字速度范围"""
|
"""设置打字速度范围"""
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
from .schedule_llm_module import LLMModel
|
from .schedule_llm_module import LLMModel
|
||||||
|
from dotenv import load_dotenv
|
||||||
from ...common.database import Database # 使用正确的导入语法
|
from ...common.database import Database # 使用正确的导入语法
|
||||||
|
|
||||||
|
|
||||||
@@ -10,9 +12,9 @@ from ...common.database import Database # 使用正确的导入语法
|
|||||||
# from src.common.database import Database # 使用正确的导入语法
|
# from src.common.database import Database # 使用正确的导入语法
|
||||||
|
|
||||||
Database.initialize(
|
Database.initialize(
|
||||||
"127.0.0.1",
|
os.getenv("MONGODB_HOST"),
|
||||||
27017,
|
int(os.getenv("MONGODB_PORT")),
|
||||||
"MegBot"
|
os.getenv("DATABASE_NAME")
|
||||||
)
|
)
|
||||||
|
|
||||||
class ScheduleGenerator:
|
class ScheduleGenerator:
|
||||||
|
|||||||
Reference in New Issue
Block a user