From 9aaa4481c57998b8c7f5829a93654c4fec7bb13b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 01:49:19 +0800
Subject: [PATCH 01/15] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E4=B8=80?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 ++
plugin/aichat/main.go | 73 +++++++++++++++++++++++++++++++++++----
plugin/manager/manager.go | 7 ++++
3 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index f48d83effb..eac66412bf 100644
--- a/README.md
+++ b/README.md
@@ -255,6 +255,8 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
- [x] 翻牌
- [x] 赞我
+
+ - [x] 群签到
- [x] [开启 | 关闭]入群验证
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 3cfa224060..f2b4c58e4e 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -9,6 +9,7 @@ import (
"github.com/fumiama/deepinfra"
"github.com/fumiama/deepinfra/model"
"github.com/sirupsen/logrus"
+ "github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -38,16 +39,24 @@ var (
"- 设置AI聊天分隔符(留空则清除)\n" +
"- 设置AI聊天(不)响应AT\n" +
"- 设置AI聊天最大长度4096\n" +
- "- 设置AI聊天TopP 0.9",
+ "- 设置AI聊天TopP 0.9\n" +
+ "- 设置AI语音群号1048452984 (tips:群里必须有AI声聊应用)\n" +
+ "- [启用|禁用]AI语音\n" +
+ "- 设置AI语音模型\n" +
+ "- 发送AI语音xxx",
PrivateDataFolder: "aichat",
})
)
-var apitypes = map[string]uint8{
- "OpenAI": 0,
- "OLLaMA": 1,
- "GenAI": 2,
-}
+var (
+ apitypes = map[string]uint8{
+ "OpenAI": 0,
+ "OLLaMA": 1,
+ "GenAI": 2,
+ }
+ customgid = int64(1048452984)
+ modelName = "lucy-voice-xueling"
+)
func init() {
en.OnMessage(ensureconfig, func(ctx *zero.Ctx) bool {
@@ -269,4 +278,56 @@ func init() {
Handle(newextrasetuint(&cfg.MaxN))
en.OnPrefix("设置AI聊天TopP", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(newextrasetfloat32(&cfg.TopP))
+ en.OnPrefix("设置AI语音群号", zero.SuperUserPermission).SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ u := strings.TrimSpace(ctx.State["args"].(string))
+ num, err := strconv.ParseInt(u, 10, 64)
+ if err != nil {
+ ctx.SendChain(message.Text("ERROR: parse gid err: ", err))
+ return
+ }
+ ctx.SendChain(message.Text("设置AI语音群号为", num))
+ customgid = num
+ })
+ en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ jsonData := ctx.GetAICharacters(customgid, 1)
+
+ // 转换为字符串数组
+ var names []string
+ // 初始化两个映射表
+ nameToID := make(map[string]string)
+ nameToURL := make(map[string]string)
+ characters := jsonData.Get("#.characters.#")
+
+ // 遍历每个角色对象
+ characters.ForEach(func(_, character gjson.Result) bool {
+ // 提取当前角色的三个字段
+ name := character.Get("character_name").String()
+ names = append(names, name)
+ id := character.Get("character_id").String()
+ url := character.Get("preview_url").String()
+
+ // 存入映射表(重复名称会覆盖,保留最后出现的条目)
+ nameToID[name] = id
+ nameToURL[name] = url
+ return true // 继续遍历
+ })
+ var builder strings.Builder
+ // 写入开头文本
+ builder.WriteString("请选择模型序号:\n")
+
+ // 遍历names数组,拼接序号和名称
+ for i, v := range names {
+ // 将数字转换为字符串(不依赖fmt)
+ numStr := strconv.Itoa(i + 1)
+ // 拼接格式:"序号. 名称\n"
+ builder.WriteString(numStr)
+ builder.WriteString(". ")
+ builder.WriteString(v)
+ builder.WriteString("\n")
+ }
+ // 获取最终字符串
+ ctx.SendChain(message.Text(builder.String()))
+ })
}
diff --git a/plugin/manager/manager.go b/plugin/manager/manager.go
index f1a6f788e8..2521412bdb 100644
--- a/plugin/manager/manager.go
+++ b/plugin/manager/manager.go
@@ -50,6 +50,7 @@ const (
"- 列出所有提醒\n" +
"- 翻牌\n" +
"- 赞我\n" +
+ "- 群签到\n" +
"- 对信息回复: 回应表情 [表情]\n" +
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}]\n" +
"- 测试欢迎语\n" +
@@ -405,6 +406,12 @@ func init() { // 插件主体
ctx.SendLike(ctx.Event.UserID, 10)
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("给你赞了10下哦,记得回我~"))
})
+ // 群签到
+ engine.OnFullMatch("群签到", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
+ Handle(func(ctx *zero.Ctx) {
+ ctx.SetGroupSign(ctx.Event.GroupID)
+ ctx.SendChain(message.Text("群签到成功,可在手机端输入框中的打卡查看"))
+ })
facere := regexp.MustCompile(`\[CQ:face,id=(\d+)\]`)
// 给消息回应表情
engine.OnRegex(`^\[CQ:reply,id=(-?\d+)\].*回应表情\s*(.+)\s*$`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).
From dd1381dfdd34e72cb933932a1c61e0e1062ec35f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 16:32:48 +0800
Subject: [PATCH 02/15] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AEAI=E8=AF=AD=E9=9F=B3=E6=A8=A1=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/cfg.go | 31 +++++++++++++++++++++++
plugin/aichat/main.go | 59 +++++++++++++++++++++++++++++++++----------
2 files changed, 76 insertions(+), 14 deletions(-)
diff --git a/plugin/aichat/cfg.go b/plugin/aichat/cfg.go
index 2d40bf04e3..2a3fe7ded4 100644
--- a/plugin/aichat/cfg.go
+++ b/plugin/aichat/cfg.go
@@ -1,6 +1,7 @@
package aichat
import (
+ "fmt"
"strconv"
"strings"
@@ -151,3 +152,33 @@ func newextrasetfloat32(ptr *float32) func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("成功"))
}
}
+
+func printConfig(cfg config) string {
+ var builder strings.Builder
+ builder.WriteString("当前AI聊天配置:\n")
+ builder.WriteString(fmt.Sprintf("• 模型名:%s\n", cfg.ModelName))
+ builder.WriteString(fmt.Sprintf("• 触发概率:%d%%\n", cfg.Type))
+ builder.WriteString(fmt.Sprintf("• 最大生成长度:%d\n", cfg.MaxN))
+ builder.WriteString(fmt.Sprintf("• TopP采样值:%.1f\n", cfg.TopP))
+ builder.WriteString(fmt.Sprintf("• 系统提示词:%s\n", cfg.SystemP))
+ builder.WriteString(fmt.Sprintf("• 接口地址:%s\n", cfg.API))
+ builder.WriteString(fmt.Sprintf("• 密钥:%s\n", maskKey(cfg.Key)))
+ builder.WriteString(fmt.Sprintf("• 分隔符:%s\n", cfg.Separator))
+ builder.WriteString(fmt.Sprintf("• 响应@:%s\n", yesNo(!cfg.NoReplyAT)))
+ builder.WriteString(fmt.Sprintf("• 支持系统提示词:%s\n", yesNo(!cfg.NoSystemP)))
+ return builder.String()
+}
+
+func maskKey(key string) string {
+ if len(key) <= 4 {
+ return "****"
+ }
+ return key[:2] + strings.Repeat("*", len(key)-4) + key[len(key)-2:]
+}
+
+func yesNo(b bool) string {
+ if b {
+ return "是"
+ }
+ return "否"
+}
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index f2b4c58e4e..53537e619b 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -5,6 +5,7 @@ import (
"math/rand"
"strconv"
"strings"
+ "time"
"github.com/fumiama/deepinfra"
"github.com/fumiama/deepinfra/model"
@@ -40,8 +41,9 @@ var (
"- 设置AI聊天(不)响应AT\n" +
"- 设置AI聊天最大长度4096\n" +
"- 设置AI聊天TopP 0.9\n" +
- "- 设置AI语音群号1048452984 (tips:群里必须有AI声聊应用)\n" +
+ "- 查看AI聊天配置\n" +
"- [启用|禁用]AI语音\n" +
+ "- 设置AI语音群号1048452984 (tips:群里必须有AI声聊应用)\n" +
"- 设置AI语音模型\n" +
"- 发送AI语音xxx",
PrivateDataFolder: "aichat",
@@ -278,6 +280,10 @@ func init() {
Handle(newextrasetuint(&cfg.MaxN))
en.OnPrefix("设置AI聊天TopP", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(newextrasetfloat32(&cfg.TopP))
+ en.OnFullMatch("查看AI聊天配置", ensureconfig, zero.SuperUserPermission).SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ ctx.SendChain(message.Text(printConfig(cfg)))
+ })
en.OnPrefix("设置AI语音群号", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u := strings.TrimSpace(ctx.State["args"].(string))
@@ -291,6 +297,9 @@ func init() {
})
en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
+ next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
+ recv, cancel := next.Repeat()
+ defer cancel()
jsonData := ctx.GetAICharacters(customgid, 1)
// 转换为字符串数组
@@ -298,29 +307,29 @@ func init() {
// 初始化两个映射表
nameToID := make(map[string]string)
nameToURL := make(map[string]string)
- characters := jsonData.Get("#.characters.#")
+ characters := jsonData.Get("#.characters")
// 遍历每个角色对象
- characters.ForEach(func(_, character gjson.Result) bool {
- // 提取当前角色的三个字段
- name := character.Get("character_name").String()
- names = append(names, name)
- id := character.Get("character_id").String()
- url := character.Get("preview_url").String()
-
- // 存入映射表(重复名称会覆盖,保留最后出现的条目)
- nameToID[name] = id
- nameToURL[name] = url
+ characters.ForEach(func(_, group gjson.Result) bool {
+ group.ForEach(func(_, character gjson.Result) bool {
+ // 提取当前角色的三个字段
+ name := character.Get("character_name").String()
+ names = append(names, name)
+ // 存入映射表(重复名称会覆盖,保留最后出现的条目)
+ nameToID[name] = character.Get("character_id").String()
+ nameToURL[name] = character.Get("preview_url").String()
+ return true // 继续遍历
+ })
return true // 继续遍历
})
var builder strings.Builder
// 写入开头文本
- builder.WriteString("请选择模型序号:\n")
+ builder.WriteString("请选择语音模型序号:\n")
// 遍历names数组,拼接序号和名称
for i, v := range names {
// 将数字转换为字符串(不依赖fmt)
- numStr := strconv.Itoa(i + 1)
+ numStr := strconv.Itoa(i)
// 拼接格式:"序号. 名称\n"
builder.WriteString(numStr)
builder.WriteString(". ")
@@ -329,5 +338,27 @@ func init() {
}
// 获取最终字符串
ctx.SendChain(message.Text(builder.String()))
+ for {
+ select {
+ case <-time.After(time.Second * 120):
+ ctx.SendChain(message.Text("设置AI语音模型指令过期"))
+ return
+ case c := <-recv:
+ msg := c.Event.Message.ExtractPlainText()
+ num, err := strconv.Atoi(msg)
+ if err != nil {
+ ctx.SendChain(message.Text("请输入数字!"))
+ continue
+ }
+ if num < 0 || num >= len(names) {
+ ctx.SendChain(message.Text("序号非法!"))
+ continue
+ }
+ modelName = nameToID[names[num]]
+ ctx.SendChain(message.Text("已选择语音模型: ", names[num]))
+ ctx.SendChain(message.Record(nameToURL[names[num]]))
+ return
+ }
+ }
})
}
From ee2c3db20ca8f82b1faf9be1d1897dbab8ab2841 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 17:36:45 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=F0=9F=94=A5=20=E6=8A=8Aai=E5=A3=B0?=
=?UTF-8?q?=E8=81=8A=E7=A7=BB=E5=8A=A8=E5=88=B0zbputils?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/cfg.go | 4 +-
plugin/aichat/main.go | 86 +------------------------------------------
2 files changed, 4 insertions(+), 86 deletions(-)
diff --git a/plugin/aichat/cfg.go b/plugin/aichat/cfg.go
index 2a3fe7ded4..a7de31a475 100644
--- a/plugin/aichat/cfg.go
+++ b/plugin/aichat/cfg.go
@@ -14,7 +14,9 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
)
-var cfg = newconfig()
+var (
+ cfg = newconfig()
+)
type config struct {
ModelName string
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 53537e619b..6cdf0330dd 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -5,12 +5,10 @@ import (
"math/rand"
"strconv"
"strings"
- "time"
"github.com/fumiama/deepinfra"
"github.com/fumiama/deepinfra/model"
"github.com/sirupsen/logrus"
- "github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
@@ -42,10 +40,7 @@ var (
"- 设置AI聊天最大长度4096\n" +
"- 设置AI聊天TopP 0.9\n" +
"- 查看AI聊天配置\n" +
- "- [启用|禁用]AI语音\n" +
- "- 设置AI语音群号1048452984 (tips:群里必须有AI声聊应用)\n" +
- "- 设置AI语音模型\n" +
- "- 发送AI语音xxx",
+ "- [启用|禁用]AI语音\n",
PrivateDataFolder: "aichat",
})
)
@@ -56,8 +51,6 @@ var (
"OLLaMA": 1,
"GenAI": 2,
}
- customgid = int64(1048452984)
- modelName = "lucy-voice-xueling"
)
func init() {
@@ -284,81 +277,4 @@ func init() {
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(printConfig(cfg)))
})
- en.OnPrefix("设置AI语音群号", zero.SuperUserPermission).SetBlock(true).
- Handle(func(ctx *zero.Ctx) {
- u := strings.TrimSpace(ctx.State["args"].(string))
- num, err := strconv.ParseInt(u, 10, 64)
- if err != nil {
- ctx.SendChain(message.Text("ERROR: parse gid err: ", err))
- return
- }
- ctx.SendChain(message.Text("设置AI语音群号为", num))
- customgid = num
- })
- en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
- Handle(func(ctx *zero.Ctx) {
- next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
- recv, cancel := next.Repeat()
- defer cancel()
- jsonData := ctx.GetAICharacters(customgid, 1)
-
- // 转换为字符串数组
- var names []string
- // 初始化两个映射表
- nameToID := make(map[string]string)
- nameToURL := make(map[string]string)
- characters := jsonData.Get("#.characters")
-
- // 遍历每个角色对象
- characters.ForEach(func(_, group gjson.Result) bool {
- group.ForEach(func(_, character gjson.Result) bool {
- // 提取当前角色的三个字段
- name := character.Get("character_name").String()
- names = append(names, name)
- // 存入映射表(重复名称会覆盖,保留最后出现的条目)
- nameToID[name] = character.Get("character_id").String()
- nameToURL[name] = character.Get("preview_url").String()
- return true // 继续遍历
- })
- return true // 继续遍历
- })
- var builder strings.Builder
- // 写入开头文本
- builder.WriteString("请选择语音模型序号:\n")
-
- // 遍历names数组,拼接序号和名称
- for i, v := range names {
- // 将数字转换为字符串(不依赖fmt)
- numStr := strconv.Itoa(i)
- // 拼接格式:"序号. 名称\n"
- builder.WriteString(numStr)
- builder.WriteString(". ")
- builder.WriteString(v)
- builder.WriteString("\n")
- }
- // 获取最终字符串
- ctx.SendChain(message.Text(builder.String()))
- for {
- select {
- case <-time.After(time.Second * 120):
- ctx.SendChain(message.Text("设置AI语音模型指令过期"))
- return
- case c := <-recv:
- msg := c.Event.Message.ExtractPlainText()
- num, err := strconv.Atoi(msg)
- if err != nil {
- ctx.SendChain(message.Text("请输入数字!"))
- continue
- }
- if num < 0 || num >= len(names) {
- ctx.SendChain(message.Text("序号非法!"))
- continue
- }
- modelName = nameToID[names[num]]
- ctx.SendChain(message.Text("已选择语音模型: ", names[num]))
- ctx.SendChain(message.Record(nameToURL[names[num]]))
- return
- }
- }
- })
}
From 4d30f3d15c65d76e1ea7f34adf56c1b87f31900f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 17:47:30 +0800
Subject: [PATCH 04/15] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E6=9D=83=E9=99=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 6cdf0330dd..fd345126aa 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -273,7 +273,7 @@ func init() {
Handle(newextrasetuint(&cfg.MaxN))
en.OnPrefix("设置AI聊天TopP", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(newextrasetfloat32(&cfg.TopP))
- en.OnFullMatch("查看AI聊天配置", ensureconfig, zero.SuperUserPermission).SetBlock(true).
+ en.OnFullMatch("查看AI聊天配置", ensureconfig).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(printConfig(cfg)))
})
From 007ee1dbf5fe4eae8783ecd31af1d860be1db9a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 17:56:22 +0800
Subject: [PATCH 05/15] =?UTF-8?q?=F0=9F=A4=A1=E6=B5=8B=E8=AF=95=E5=AF=BC?=
=?UTF-8?q?=E5=8C=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/main.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index fd345126aa..9b70c10aab 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -2,6 +2,7 @@
package aichat
import (
+ "fmt"
"math/rand"
"strconv"
"strings"
@@ -15,6 +16,7 @@ import (
"github.com/FloatTech/floatbox/process"
ctrl "github.com/FloatTech/zbpctrl"
+ "github.com/FloatTech/zbputils/airecord"
"github.com/FloatTech/zbputils/chat"
"github.com/FloatTech/zbputils/control"
)
@@ -139,6 +141,8 @@ func init() {
if t == "" {
continue
}
+ recCfg := airecord.GetRecordConfig()
+ fmt.Println(recCfg)
if id != nil {
id = ctx.SendChain(message.Reply(id), message.Text(t))
} else {
From 7cf6ccc736023bd920c9c10efb2b0ee898679526 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 23:37:46 +0800
Subject: [PATCH 06/15] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E4=BB=A5?=
=?UTF-8?q?=E8=AF=AD=E9=9F=B3=E8=BE=93=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/cfg.go | 20 +++++++++++++++----
plugin/aichat/main.go | 45 +++++++++++++++++++++++++++++++++++--------
2 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/plugin/aichat/cfg.go b/plugin/aichat/cfg.go
index a7de31a475..f92875320e 100644
--- a/plugin/aichat/cfg.go
+++ b/plugin/aichat/cfg.go
@@ -29,6 +29,7 @@ type config struct {
Separator string
NoReplyAT bool
NoSystemP bool
+ NoRecord bool
}
func newconfig() config {
@@ -155,19 +156,30 @@ func newextrasetfloat32(ptr *float32) func(ctx *zero.Ctx) {
}
}
-func printConfig(cfg config) string {
+func printConfig(rate int64, temperature int64, cfg config) string {
+ maxn := cfg.MaxN
+ if maxn == 0 {
+ maxn = 4096
+ }
+ topp := cfg.TopP
+ if topp == 0 {
+ topp = 0.9
+ }
var builder strings.Builder
builder.WriteString("当前AI聊天配置:\n")
builder.WriteString(fmt.Sprintf("• 模型名:%s\n", cfg.ModelName))
- builder.WriteString(fmt.Sprintf("• 触发概率:%d%%\n", cfg.Type))
- builder.WriteString(fmt.Sprintf("• 最大生成长度:%d\n", cfg.MaxN))
- builder.WriteString(fmt.Sprintf("• TopP采样值:%.1f\n", cfg.TopP))
+ builder.WriteString(fmt.Sprintf("• 接口类型:%d(%s)\n", cfg.Type, apilist[cfg.Type]))
+ builder.WriteString(fmt.Sprintf("• 触发概率:%d%%\n", rate))
+ builder.WriteString(fmt.Sprintf("• 温度:%.2f\n", float32(temperature)/100))
+ builder.WriteString(fmt.Sprintf("• 最大长度:%d\n", maxn))
+ builder.WriteString(fmt.Sprintf("• TopP:%.1f\n", topp))
builder.WriteString(fmt.Sprintf("• 系统提示词:%s\n", cfg.SystemP))
builder.WriteString(fmt.Sprintf("• 接口地址:%s\n", cfg.API))
builder.WriteString(fmt.Sprintf("• 密钥:%s\n", maskKey(cfg.Key)))
builder.WriteString(fmt.Sprintf("• 分隔符:%s\n", cfg.Separator))
builder.WriteString(fmt.Sprintf("• 响应@:%s\n", yesNo(!cfg.NoReplyAT)))
builder.WriteString(fmt.Sprintf("• 支持系统提示词:%s\n", yesNo(!cfg.NoSystemP)))
+ builder.WriteString(fmt.Sprintf("• 以AI语音输出:%s\n", yesNo(!cfg.NoRecord)))
return builder.String()
}
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 9b70c10aab..c6009f68f4 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -2,7 +2,6 @@
package aichat
import (
- "fmt"
"math/rand"
"strconv"
"strings"
@@ -41,8 +40,8 @@ var (
"- 设置AI聊天(不)响应AT\n" +
"- 设置AI聊天最大长度4096\n" +
"- 设置AI聊天TopP 0.9\n" +
- "- 查看AI聊天配置\n" +
- "- [启用|禁用]AI语音\n",
+ "- 设置AI聊天(不)以AI语音输出\n" +
+ "- 查看AI聊天配置\n",
PrivateDataFolder: "aichat",
})
)
@@ -53,6 +52,7 @@ var (
"OLLaMA": 1,
"GenAI": 2,
}
+ apilist = [3]string{"OpenAI", "OLLaMA", "GenAI"}
)
func init() {
@@ -141,12 +141,25 @@ func init() {
if t == "" {
continue
}
+ logrus.Infoln("[aichat] 回复内容:", t)
recCfg := airecord.GetRecordConfig()
- fmt.Println(recCfg)
- if id != nil {
- id = ctx.SendChain(message.Reply(id), message.Text(t))
+ if !cfg.NoRecord {
+ record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t).String()
+ if record != "" {
+ ctx.SendChain(message.Record(record))
+ } else {
+ if id != nil {
+ id = ctx.SendChain(message.Reply(id), message.Text(t))
+ } else {
+ id = ctx.SendChain(message.Text(t))
+ }
+ }
} else {
- id = ctx.SendChain(message.Text(t))
+ if id != nil {
+ id = ctx.SendChain(message.Reply(id), message.Text(t))
+ } else {
+ id = ctx.SendChain(message.Text(t))
+ }
}
process.SleepAbout1sTo2s()
}
@@ -277,8 +290,24 @@ func init() {
Handle(newextrasetuint(&cfg.MaxN))
en.OnPrefix("设置AI聊天TopP", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(newextrasetfloat32(&cfg.TopP))
+ en.OnRegex("^设置AI聊天(不)?以AI语音输出$", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
+ Handle(newextrasetbool(&cfg.NoRecord))
en.OnFullMatch("查看AI聊天配置", ensureconfig).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
- ctx.SendChain(message.Text(printConfig(cfg)))
+ c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
+ if !ok {
+ ctx.SendChain(message.Text("ERROR: no such plugin"))
+ return
+ }
+ gid := ctx.Event.GroupID
+ rate := c.GetData(gid) & 0xff
+ temp := (c.GetData(gid) >> 8) & 0xff
+ if temp <= 0 {
+ temp = 70 // default setting
+ }
+ if temp > 100 {
+ temp = 100
+ }
+ ctx.SendChain(message.Text(printConfig(rate, temp, cfg)))
})
}
From afb735a5cda474e555d48cd1a8f3d1ecaea5ea60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Fri, 4 Jul 2025 23:58:21 +0800
Subject: [PATCH 07/15] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E4=B8=80=E4=B8=8B=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 18 +++++++++++++++++-
plugin/aichat/main.go | 2 +-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index eac66412bf..9d0dd8a8f7 100644
--- a/README.md
+++ b/README.md
@@ -278,6 +278,20 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
- 设置欢迎语可选添加参数说明:{at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名
+
+
+ 群应用:AI声聊
+
+ `import _ "github.com/FloatTech/zbputils/airecord"`
+
+ - [x] 设置AI语音群号1048452984(tips:机器人任意所在群聊即可)
+
+ - [x] 设置AI语音模型
+
+ - [x] 查看AI语音配置
+
+ - [x] 发送AI语音xxx
+
定时指令触发器
@@ -1582,7 +1596,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 设置AI聊天温度80
- [x] 设置AI聊天接口类型[OpenAI|OLLaMA|GenAI]
- [x] 设置AI聊天(不)支持系统提示词
- - [x] 设置AI聊天接口地址https://xxx
+ - [x] 设置AI聊天接口地址https://api.deepseek.com/chat/completions
- [x] 设置AI聊天密钥xxx
- [x] 设置AI聊天模型名xxx
- [x] 查看AI聊天系统提示词
@@ -1592,6 +1606,8 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 设置AI聊天(不)响应AT
- [x] 设置AI聊天最大长度4096
- [x] 设置AI聊天TopP 0.9
+ - [x] 设置AI聊天(不)以AI语音输出
+ - [x] 查看AI聊天配置
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index c6009f68f4..bd5001003c 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -30,7 +30,7 @@ var (
"- 设置AI聊天温度80\n" +
"- 设置AI聊天接口类型[OpenAI|OLLaMA|GenAI]\n" +
"- 设置AI聊天(不)支持系统提示词\n" +
- "- 设置AI聊天接口地址https://xxx\n" +
+ "- 设置AI聊天接口地址https://api.deepseek.com/chat/completions\n" +
"- 设置AI聊天密钥xxx\n" +
"- 设置AI聊天模型名xxx\n" +
"- 查看AI聊天系统提示词\n" +
From c8c3cc5bf66fb812ad0ecd3268ea717fb1aaee2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Sat, 5 Jul 2025 22:23:05 +0800
Subject: [PATCH 08/15] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0AI=E5=A3=B0?=
=?UTF-8?q?=E8=81=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
plugin/aichat/main.go | 2 +-
plugin/airecord/record.go | 124 ++++++++++++++++++++++++++++++++++++++
3 files changed, 126 insertions(+), 2 deletions(-)
create mode 100644 plugin/airecord/record.go
diff --git a/README.md b/README.md
index 7e37897815..988beba65b 100644
--- a/README.md
+++ b/README.md
@@ -282,7 +282,7 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
群应用:AI声聊
- `import _ "github.com/FloatTech/zbputils/airecord"`
+ `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/airecord"`
- [x] 设置AI语音群号1048452984(tips:机器人任意所在群聊即可)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index bd5001003c..381b1bdc76 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -144,7 +144,7 @@ func init() {
logrus.Infoln("[aichat] 回复内容:", t)
recCfg := airecord.GetRecordConfig()
if !cfg.NoRecord {
- record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t).String()
+ record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
if record != "" {
ctx.SendChain(message.Record(record))
} else {
diff --git a/plugin/airecord/record.go b/plugin/airecord/record.go
new file mode 100644
index 0000000000..5968663a57
--- /dev/null
+++ b/plugin/airecord/record.go
@@ -0,0 +1,124 @@
+// Package airecord 群应用:AI声聊
+package airecord
+
+import (
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/tidwall/gjson"
+
+ zero "github.com/wdvxdr1123/ZeroBot"
+ "github.com/wdvxdr1123/ZeroBot/message"
+
+ ctrl "github.com/FloatTech/zbpctrl"
+ "github.com/FloatTech/zbputils/airecord"
+ "github.com/FloatTech/zbputils/control"
+)
+
+func init() {
+ en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
+ DisableOnDefault: false,
+ Extra: control.ExtraFromString("airecord"),
+ Brief: "群应用:AI声聊",
+ Help: "- 设置AI语音群号1048452984(tips:机器人任意所在群聊即可)\n" +
+ "- 设置AI语音模型\n" +
+ "- 查看AI语音配置\n" +
+ "- 发送AI语音xxx",
+ PrivateDataFolder: "airecord",
+ })
+
+ en.OnPrefix("设置AI语音群号", zero.SuperUserPermission).SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ u := strings.TrimSpace(ctx.State["args"].(string))
+ num, err := strconv.ParseInt(u, 10, 64)
+ if err != nil {
+ ctx.SendChain(message.Text("ERROR: parse gid err: ", err))
+ return
+ }
+ airecord.SetCustomGID(num)
+ ctx.SendChain(message.Text("设置AI语音群号为", num))
+ })
+ en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
+ recv, cancel := next.Repeat()
+ defer cancel()
+ jsonData := ctx.GetAICharacters(0, 1)
+
+ // 转换为字符串数组
+ var names []string
+ // 初始化两个映射表
+ nameToID := make(map[string]string)
+ nameToURL := make(map[string]string)
+ characters := jsonData.Get("#.characters")
+
+ // 遍历每个角色对象
+ characters.ForEach(func(_, group gjson.Result) bool {
+ group.ForEach(func(_, character gjson.Result) bool {
+ // 提取当前角色的三个字段
+ name := character.Get("character_name").String()
+ names = append(names, name)
+ // 存入映射表(重复名称会覆盖,保留最后出现的条目)
+ nameToID[name] = character.Get("character_id").String()
+ nameToURL[name] = character.Get("preview_url").String()
+ return true // 继续遍历
+ })
+ return true // 继续遍历
+ })
+ var builder strings.Builder
+ // 写入开头文本
+ builder.WriteString("请选择语音模型序号:\n")
+
+ // 遍历names数组,拼接序号和名称
+ for i, v := range names {
+ // 将数字转换为字符串(不依赖fmt)
+ numStr := strconv.Itoa(i)
+ // 拼接格式:"序号. 名称\n"
+ builder.WriteString(numStr)
+ builder.WriteString(". ")
+ builder.WriteString(v)
+ builder.WriteString("\n")
+ }
+ // 获取最终字符串
+ ctx.SendChain(message.Text(builder.String()))
+ for {
+ select {
+ case <-time.After(time.Second * 120):
+ ctx.SendChain(message.Text("设置AI语音模型指令过期"))
+ return
+ case ct := <-recv:
+ msg := ct.Event.Message.ExtractPlainText()
+ num, err := strconv.Atoi(msg)
+ if err != nil {
+ ctx.SendChain(message.Text("请输入数字!"))
+ continue
+ }
+ if num < 0 || num >= len(names) {
+ ctx.SendChain(message.Text("序号非法!"))
+ continue
+ }
+ airecord.SetRecordModel(names[num], nameToID[names[num]])
+ ctx.SendChain(message.Text("已选择语音模型: ", names[num]))
+ ctx.SendChain(message.Record(nameToURL[names[num]]))
+ return
+ }
+ }
+ })
+ en.OnFullMatch("查看AI语音配置").SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ recCfg := airecord.GetRecordConfig()
+ ctx.SendChain(message.Text(airecord.PrintRecordConfig(recCfg)))
+ })
+ en.OnPrefix("发送AI语音").SetBlock(true).
+ Handle(func(ctx *zero.Ctx) {
+ u := strings.TrimSpace(ctx.State["args"].(string))
+ recCfg := airecord.GetRecordConfig()
+ record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, u)
+ if record == "" {
+ ctx.SendChain(message.Text("ERROR: get record err: empty record"))
+ return
+ }
+ ctx.SendChain(message.Record(record))
+ })
+}
From 7e8539c8eac08a9eb4d2a12424fccaeb4489fb99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Sat, 5 Jul 2025 23:23:29 +0800
Subject: [PATCH 09/15] =?UTF-8?q?=F0=9F=8E=A8=20=E5=B0=BD=E9=87=8F?=
=?UTF-8?q?=E5=8F=91=E9=80=81=E5=A3=B0=E9=9F=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/airecord/record.go | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/plugin/airecord/record.go b/plugin/airecord/record.go
index 5968663a57..dd6695dce3 100644
--- a/plugin/airecord/record.go
+++ b/plugin/airecord/record.go
@@ -116,8 +116,11 @@ func init() {
recCfg := airecord.GetRecordConfig()
record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, u)
if record == "" {
- ctx.SendChain(message.Text("ERROR: get record err: empty record"))
- return
+ id := ctx.SendGroupAIRecord(recCfg.ModelID, ctx.Event.GroupID, u)
+ if id == "" {
+ ctx.SendChain(message.Text("ERROR: get record err: empty record"))
+ return
+ }
}
ctx.SendChain(message.Record(record))
})
From 97f36f455479740c79d0228ae7c4560cdeef3f65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Mon, 7 Jul 2025 23:42:26 +0800
Subject: [PATCH 10/15] =?UTF-8?q?=E2=9C=A8=20=E4=BF=AE=E6=94=B9=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
go.mod | 4 ++--
go.sum | 8 ++++----
main.go | 2 ++
plugin/aichat/main.go | 4 ++--
plugin/airecord/record.go | 18 +++++++++++++-----
5 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/go.mod b/go.mod
index 6e5daf610a..773ff75299 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.20
require (
github.com/Baidu-AIP/golang-sdk v1.1.1
- github.com/FloatTech/AnimeAPI v1.7.1-0.20250530055006-50f5c7587c5b
+ github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80
github.com/FloatTech/gg v1.1.3
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef
@@ -45,7 +45,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/tidwall/gjson v1.18.0
github.com/wcharczuk/go-chart/v2 v2.1.2
- github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250330133859-27c25d9412b5
+ github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250707133321-6197b8ee5df7
gitlab.com/gomidi/midi/v2 v2.1.7
golang.org/x/image v0.24.0
golang.org/x/sys v0.30.0
diff --git a/go.sum b/go.sum
index ee423745dc..7f33f6780f 100644
--- a/go.sum
+++ b/go.sum
@@ -1,8 +1,8 @@
github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhvrx4cw=
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
-github.com/FloatTech/AnimeAPI v1.7.1-0.20250530055006-50f5c7587c5b h1:H/1xpchTGmdoHqrszH4gjafCyHIhsGSFryAkBNsu8OI=
-github.com/FloatTech/AnimeAPI v1.7.1-0.20250530055006-50f5c7587c5b/go.mod h1:XXG1eBJf+eeWacQx5azsQKL5Gg7jDYTFyyZGIa/56js=
+github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923 h1:TECdoqZCompmyISzkFkMxSzxGtO3n9VhR+s/r3WwjwQ=
+github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923/go.mod h1:XXG1eBJf+eeWacQx5azsQKL5Gg7jDYTFyyZGIa/56js=
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80 h1:lFD1pd8NkYCrw0QpTX/T5pJ67I7AL5eGxQ4v0r9f81Q=
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80/go.mod h1:IWoFFqu+0FeaHHQdddyiTRL5z7gJME6qHC96qh0R2sc=
github.com/FloatTech/gg v1.1.3 h1:+GlL02lTKsxJQr4WCuNwVxC1/eBZrCvypCIBtxuOFb4=
@@ -199,8 +199,8 @@ github.com/vcaesar/cedar v0.20.2/go.mod h1:lyuGvALuZZDPNXwpzv/9LyxW+8Y6faN7zauFe
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
github.com/wcharczuk/go-chart/v2 v2.1.2 h1:Y17/oYNuXwZg6TFag06qe8sBajwwsuvPiJJXcUcLL6E=
github.com/wcharczuk/go-chart/v2 v2.1.2/go.mod h1:Zi4hbaqlWpYajnXB2K22IUYVXRXaLfSGNNR7P4ukyyQ=
-github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250330133859-27c25d9412b5 h1:HsMcBsVpYuQv+W8pjX5WdwYROrFQP9c5Pbf4x4adDus=
-github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250330133859-27c25d9412b5/go.mod h1:C86nQ0gIdAri4K2vg8IIQIslt08zzrKMcqYt8zhkx1M=
+github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250707133321-6197b8ee5df7 h1:ya+lVbCC/EN5JumpQDDlVCSrWzLwHl4CHzlTANKDvrU=
+github.com/wdvxdr1123/ZeroBot v1.8.2-0.20250707133321-6197b8ee5df7/go.mod h1:C86nQ0gIdAri4K2vg8IIQIslt08zzrKMcqYt8zhkx1M=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
diff --git a/main.go b/main.go
index a260c25857..5e9b13e577 100644
--- a/main.go
+++ b/main.go
@@ -38,6 +38,8 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleepmanage" // 统计睡眠时间
+ _ "github.com/FloatTech/ZeroBot-Plugin/plugin/airecord" // 群应用:AI声聊
+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/manager" // 群管
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 381b1bdc76..4f6275bf90 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -13,9 +13,9 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
+ "github.com/FloatTech/AnimeAPI/airecord"
"github.com/FloatTech/floatbox/process"
ctrl "github.com/FloatTech/zbpctrl"
- "github.com/FloatTech/zbputils/airecord"
"github.com/FloatTech/zbputils/chat"
"github.com/FloatTech/zbputils/control"
)
@@ -142,7 +142,7 @@ func init() {
continue
}
logrus.Infoln("[aichat] 回复内容:", t)
- recCfg := airecord.GetRecordConfig()
+ recCfg := airecord.RecCfg
if !cfg.NoRecord {
record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
if record != "" {
diff --git a/plugin/airecord/record.go b/plugin/airecord/record.go
index dd6695dce3..00e0ac1a3c 100644
--- a/plugin/airecord/record.go
+++ b/plugin/airecord/record.go
@@ -11,8 +11,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
+ "github.com/FloatTech/AnimeAPI/airecord"
ctrl "github.com/FloatTech/zbpctrl"
- "github.com/FloatTech/zbputils/airecord"
"github.com/FloatTech/zbputils/control"
)
@@ -36,7 +36,11 @@ func init() {
ctx.SendChain(message.Text("ERROR: parse gid err: ", err))
return
}
- airecord.SetCustomGID(num)
+ err = airecord.SetCustomGID(num)
+ if err != nil {
+ ctx.SendChain(message.Text("ERROR: set gid err: ", err))
+ return
+ }
ctx.SendChain(message.Text("设置AI语音群号为", num))
})
en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
@@ -98,7 +102,11 @@ func init() {
ctx.SendChain(message.Text("序号非法!"))
continue
}
- airecord.SetRecordModel(names[num], nameToID[names[num]])
+ err = airecord.SetRecordModel(names[num], nameToID[names[num]])
+ if err != nil {
+ ctx.SendChain(message.Text("ERROR: set model err: ", err))
+ continue
+ }
ctx.SendChain(message.Text("已选择语音模型: ", names[num]))
ctx.SendChain(message.Record(nameToURL[names[num]]))
return
@@ -107,13 +115,13 @@ func init() {
})
en.OnFullMatch("查看AI语音配置").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
- recCfg := airecord.GetRecordConfig()
+ recCfg := airecord.RecCfg
ctx.SendChain(message.Text(airecord.PrintRecordConfig(recCfg)))
})
en.OnPrefix("发送AI语音").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u := strings.TrimSpace(ctx.State["args"].(string))
- recCfg := airecord.GetRecordConfig()
+ recCfg := airecord.RecCfg
record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, u)
if record == "" {
id := ctx.SendGroupAIRecord(recCfg.ModelID, ctx.Event.GroupID, u)
From 981298e87728e2cc7de732b891b79d8a9c5f07dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Wed, 16 Jul 2025 21:00:46 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E2=9C=A8=20=E4=BF=AE=E6=94=B9=E6=9D=83?=
=?UTF-8?q?=E9=99=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/main.go | 2 +-
plugin/airecord/record.go | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 4f6275bf90..a8214230c7 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -292,7 +292,7 @@ func init() {
Handle(newextrasetfloat32(&cfg.TopP))
en.OnRegex("^设置AI聊天(不)?以AI语音输出$", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(newextrasetbool(&cfg.NoRecord))
- en.OnFullMatch("查看AI聊天配置", ensureconfig).SetBlock(true).
+ en.OnFullMatch("查看AI聊天配置", ensureconfig, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
diff --git a/plugin/airecord/record.go b/plugin/airecord/record.go
index 00e0ac1a3c..6a3452f80c 100644
--- a/plugin/airecord/record.go
+++ b/plugin/airecord/record.go
@@ -28,7 +28,7 @@ func init() {
PrivateDataFolder: "airecord",
})
- en.OnPrefix("设置AI语音群号", zero.SuperUserPermission).SetBlock(true).
+ en.OnPrefix("设置AI语音群号", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u := strings.TrimSpace(ctx.State["args"].(string))
num, err := strconv.ParseInt(u, 10, 64)
@@ -43,7 +43,7 @@ func init() {
}
ctx.SendChain(message.Text("设置AI语音群号为", num))
})
- en.OnFullMatch("设置AI语音模型", zero.SuperUserPermission).SetBlock(true).
+ en.OnFullMatch("设置AI语音模型", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession())
recv, cancel := next.Repeat()
@@ -113,12 +113,12 @@ func init() {
}
}
})
- en.OnFullMatch("查看AI语音配置").SetBlock(true).
+ en.OnFullMatch("查看AI语音配置", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
recCfg := airecord.RecCfg
ctx.SendChain(message.Text(airecord.PrintRecordConfig(recCfg)))
})
- en.OnPrefix("发送AI语音").SetBlock(true).
+ en.OnPrefix("发送AI语音", zero.UserOrGrpAdmin).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u := strings.TrimSpace(ctx.State["args"].(string))
recCfg := airecord.RecCfg
From d6e63426df7ec03606b389e91b260175d915e66a Mon Sep 17 00:00:00 2001
From: himawari <54976075+guohuiyuan@users.noreply.github.com>
Date: Wed, 16 Jul 2025 22:31:41 +0800
Subject: [PATCH 12/15] Update plugin/aichat/main.go
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
---
plugin/aichat/main.go | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index a8214230c7..21c8660215 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -142,18 +142,12 @@ func init() {
continue
}
logrus.Infoln("[aichat] 回复内容:", t)
- recCfg := airecord.RecCfg
+ record := ""
if !cfg.NoRecord {
- record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
- if record != "" {
- ctx.SendChain(message.Record(record))
- } else {
- if id != nil {
- id = ctx.SendChain(message.Reply(id), message.Text(t))
- } else {
- id = ctx.SendChain(message.Text(t))
- }
- }
+ record = ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
+ }
+ if record != "" {
+ ctx.SendChain(message.Record(record))
} else {
if id != nil {
id = ctx.SendChain(message.Reply(id), message.Text(t))
From ab933df827dc678740c374be1e483f5f22366f26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Wed, 16 Jul 2025 22:36:57 +0800
Subject: [PATCH 13/15] =?UTF-8?q?=F0=9F=90=9B=20=E5=AF=BC=E5=8C=85?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/aichat/main.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 21c8660215..6dbdb2c4cf 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -142,6 +142,7 @@ func init() {
continue
}
logrus.Infoln("[aichat] 回复内容:", t)
+ recCfg := airecord.RecCfg
record := ""
if !cfg.NoRecord {
record = ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
From f594161cf21650f6adcba77b3984a0a9755cd7ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Thu, 17 Jul 2025 20:39:49 +0800
Subject: [PATCH 14/15] =?UTF-8?q?=E2=9C=A8=20=E4=BF=AE=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
go.mod | 2 +-
go.sum | 4 ++--
plugin/aichat/main.go | 2 +-
plugin/airecord/record.go | 5 ++---
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/go.mod b/go.mod
index 773ff75299..c319db1c9e 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.20
require (
github.com/Baidu-AIP/golang-sdk v1.1.1
- github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923
+ github.com/FloatTech/AnimeAPI v1.7.1-0.20250717123723-d300df538b46
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80
github.com/FloatTech/gg v1.1.3
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef
diff --git a/go.sum b/go.sum
index 7f33f6780f..d4b9a61146 100644
--- a/go.sum
+++ b/go.sum
@@ -1,8 +1,8 @@
github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhvrx4cw=
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
-github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923 h1:TECdoqZCompmyISzkFkMxSzxGtO3n9VhR+s/r3WwjwQ=
-github.com/FloatTech/AnimeAPI v1.7.1-0.20250707153806-5f9e921b8923/go.mod h1:XXG1eBJf+eeWacQx5azsQKL5Gg7jDYTFyyZGIa/56js=
+github.com/FloatTech/AnimeAPI v1.7.1-0.20250717123723-d300df538b46 h1:X6ZbOWoZJIoHCin+CeU92Q3EwpvglyQ4gc5BZhOtAwo=
+github.com/FloatTech/AnimeAPI v1.7.1-0.20250717123723-d300df538b46/go.mod h1:XXG1eBJf+eeWacQx5azsQKL5Gg7jDYTFyyZGIa/56js=
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80 h1:lFD1pd8NkYCrw0QpTX/T5pJ67I7AL5eGxQ4v0r9f81Q=
github.com/FloatTech/floatbox v0.0.0-20250513111443-adba80e84e80/go.mod h1:IWoFFqu+0FeaHHQdddyiTRL5z7gJME6qHC96qh0R2sc=
github.com/FloatTech/gg v1.1.3 h1:+GlL02lTKsxJQr4WCuNwVxC1/eBZrCvypCIBtxuOFb4=
diff --git a/plugin/aichat/main.go b/plugin/aichat/main.go
index 6dbdb2c4cf..c8ac1df646 100644
--- a/plugin/aichat/main.go
+++ b/plugin/aichat/main.go
@@ -142,7 +142,7 @@ func init() {
continue
}
logrus.Infoln("[aichat] 回复内容:", t)
- recCfg := airecord.RecCfg
+ recCfg := airecord.GetConfig()
record := ""
if !cfg.NoRecord {
record = ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, t)
diff --git a/plugin/airecord/record.go b/plugin/airecord/record.go
index 6a3452f80c..908784d483 100644
--- a/plugin/airecord/record.go
+++ b/plugin/airecord/record.go
@@ -115,13 +115,12 @@ func init() {
})
en.OnFullMatch("查看AI语音配置", zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
- recCfg := airecord.RecCfg
- ctx.SendChain(message.Text(airecord.PrintRecordConfig(recCfg)))
+ ctx.SendChain(message.Text(airecord.PrintRecordConfig()))
})
en.OnPrefix("发送AI语音", zero.UserOrGrpAdmin).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
u := strings.TrimSpace(ctx.State["args"].(string))
- recCfg := airecord.RecCfg
+ recCfg := airecord.GetConfig()
record := ctx.GetAIRecord(recCfg.ModelID, recCfg.Customgid, u)
if record == "" {
id := ctx.SendGroupAIRecord(recCfg.ModelID, ctx.Event.GroupID, u)
From f4d23920093015ab48a5d8b10ca69874da8b10b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E9=94=85=E9=A5=AD?= <1156544355@qq.com>
Date: Thu, 17 Jul 2025 20:46:42 +0800
Subject: [PATCH 15/15] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin/bilibili/bilibili_parse.go | 7 ++++++-
plugin/bilibili/card2msg_test.go | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/plugin/bilibili/bilibili_parse.go b/plugin/bilibili/bilibili_parse.go
index b094e0e88e..189c6586f2 100644
--- a/plugin/bilibili/bilibili_parse.go
+++ b/plugin/bilibili/bilibili_parse.go
@@ -163,7 +163,12 @@ func handleArticle(ctx *zero.Ctx) {
}
func handleLive(ctx *zero.Ctx) {
- card, err := bz.GetLiveRoomInfo(ctx.State["regex_matched"].([]string)[1])
+ cookie, err := cfg.Load()
+ if err != nil {
+ ctx.SendChain(message.Text("ERROR: ", err))
+ return
+ }
+ card, err := bz.GetLiveRoomInfo(ctx.State["regex_matched"].([]string)[1], cookie)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
diff --git a/plugin/bilibili/card2msg_test.go b/plugin/bilibili/card2msg_test.go
index 5c43c8491c..5d85d77507 100644
--- a/plugin/bilibili/card2msg_test.go
+++ b/plugin/bilibili/card2msg_test.go
@@ -47,7 +47,7 @@ func TestVideoInfo(t *testing.T) {
}
func TestLiveRoomInfo(t *testing.T) {
- card, err := bz.GetLiveRoomInfo("83171")
+ card, err := bz.GetLiveRoomInfo("83171", "b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;")
if err != nil {
t.Fatal(err)
}