diff --git a/.gitignore b/.gitignore index 569831e..f282510 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ data .venv go_al/*.go onebot/onebot -*.tar.gz \ No newline at end of file +*.tar.gz +release \ No newline at end of file diff --git a/onebot/build.sh b/build.sh similarity index 62% rename from onebot/build.sh rename to build.sh index 0f0fd68..540a3a7 100755 --- a/onebot/build.sh +++ b/build.sh @@ -5,8 +5,8 @@ set -e # --- 配置区 --- BINARY_NAME="onebot" -JS_FILE="script.js" -OUTPUT_TAR="onebot_package_mac_arm64.tar.gz" +JS_FILE="./onebot/script.js" +OUTPUT_TAR="./release/onebot_mac_arm64.tar.gz" GO_SOURCE_PATH="." # 假设你的 main.go 在当前目录 echo "🚀 开始构建流程..." @@ -16,20 +16,13 @@ echo "📦 正在编译 Go 二进制文件 [$BINARY_NAME]..." # 如果你需要交叉编译(例如在 Mac 上编译 Linux 版本),可以取消下面两行的注释 # export GOOS=linux # export GOARCH=amd64 +cd ./onebot go build -o $BINARY_NAME $GO_SOURCE_PATH -# 2. 检查必需的文件是否存在 -if [ ! -f "$JS_FILE" ]; then - echo "❌ 错误: 找不到 $JS_FILE 文件!" - exit 1 -fi - -# 3. 创建打包目录(为了保证 tar 包内路径整洁,建议先考入临时目录) +# 2. 创建打包目录(为了保证 tar 包内路径整洁,建议先考入临时目录) echo "📂 正在打包文件..." -tar -czvf $OUTPUT_TAR $BINARY_NAME $JS_FILE - -# 4. 清理编译出的二进制文件(可选) -# rm $BINARY_NAME +cd .. +tar -czvf $OUTPUT_TAR ./onebot/onebot $JS_FILE ./wechat_version echo "✅ 构建完成!生成文件: $OUTPUT_TAR" echo "📄 包内包含: $(tar -tf $OUTPUT_TAR)" \ No newline at end of file diff --git a/onebot/main.go b/onebot/main.go index c4c2204..5beaf62 100644 --- a/onebot/main.go +++ b/onebot/main.go @@ -286,7 +286,7 @@ func SendWechatMsg(m *SendMsg) { currTaskId := atomic.AddInt64(&taskId, 1) log.Printf("📩 收到任务: %d\n", currTaskId) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() targetId := m.UserId diff --git a/onebot/script.js b/onebot/script.js index 2a8dba7..2cf1ac6 100644 --- a/onebot/script.js +++ b/onebot/script.js @@ -1122,14 +1122,20 @@ function setReceiver() { } } - senderUser = content.substring(0, splitIndex).trim(); + const sendUserStart = content.indexOf('wxid_') + senderUser = content.substring(sendUserStart, splitIndex).trim(); messages = []; const parts = content.split('\u2005'); for (let part of parts) { part = part.trim(); if (!part.startsWith("@")) { - messages.push({type: "text", data: {text: part}}); + if (part.indexOf(":") !== -1) { + messages.push({type: "text", data: {text: part.substring(part.indexOf(':') + 1)}}); + } else { + messages.push({type: "text", data: {text: part}}); + } + } }