Skip to content

Commit

Permalink
移除ChatGPT & 默认注释 thesaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jan 9, 2023
1 parent c99d09e commit 8ca7196
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 157 deletions.
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,6 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-p prefix] [-d|w] [-c|s config.j

- 设置欢迎语可选添加参数说明:{at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名

</details>
<details>
<summary>词典匹配回复</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"`

- [x] 切换[kimo|傲娇|可爱]词库
- [x] 设置词库触发概率0.x (0<x<9)

</details>
<details>
<summary>定时指令触发器</summary>
Expand Down Expand Up @@ -1389,6 +1380,17 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 查卡店 [卡名] -r [稀有度]
- 注:卡店只支持单个稀有度查询

</details>
<details>
<summary>词典匹配回复</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus"`

- [x] 切换[kimo|傲娇|可爱]词库
- [x] 设置词库触发概率0.x (0<x<9)

- 注:由于占用资源较大,默认注释。

</details>
<details>
<summary>鬼东西</summary>
Expand Down Expand Up @@ -1422,15 +1424,7 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] @Bot 任意文本(任意一句话回复)

- [x] 设置回复模式[青云客 | 小爱 | ChatGPT]

- [x] 设置 ChatGPT SessionToken xxx

- [x] 重置ChatGPT连接

- 注:
- 注册和获取 token 可以参见这两篇文章:[注册](https://www.cnblogs.com/ranxi169/p/16954797.html) [获取token](https://juejin.cn/post/7174088036035067917)
- 设置 SessionToken 时,请确保自己为超级管理员,然后私聊`/响应` `/禁用atri` `/禁用tts` `/启用aireply`,再发送`设置 ChatGPT SessionToken xxx`
- [x] 设置回复模式[青云客 | 小爱]

</details>

Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ go 1.19
require (
github.com/Baidu-AIP/golang-sdk v1.1.1
github.com/Coloured-glaze/gg v1.3.4
github.com/FloatTech/AnimeAPI v1.6.1-0.20230107074849-392b0b10b149
github.com/FloatTech/floatbox v0.0.0-20230107061309-dcd5c0012dd3
github.com/FloatTech/AnimeAPI v1.6.1-0.20230109125955-02d902ce0951
github.com/FloatTech/floatbox v0.0.0-20230109123116-c544925718fe
github.com/FloatTech/sqlite v1.5.7
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
github.com/FloatTech/zbpctrl v1.5.3-0.20221210051848-740ab7bd6ec3
github.com/FloatTech/zbputils v1.6.1-0.20230107061700-dadcf8500e7a
github.com/FloatTech/zbpctrl v1.5.3-0.20230109124217-41203036b80a
github.com/FloatTech/zbputils v1.6.1-0.20230109125328-bf06bab484de
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
github.com/antchfx/htmlquery v1.2.5
github.com/corona10/goimagehash v1.1.0
github.com/fumiama/ahsai v0.1.0
github.com/fumiama/cron v1.3.0
github.com/fumiama/go-base16384 v1.6.1
github.com/fumiama/go-registry v0.2.5-0.20221121111817-44b0846bdce6
github.com/fumiama/go-base16384 v1.6.4
github.com/fumiama/go-registry v0.2.5
github.com/fumiama/gotracemoe v0.0.3
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
Expand All @@ -32,7 +32,7 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/tidwall/gjson v1.14.4
github.com/wcharczuk/go-chart/v2 v2.1.0
github.com/wdvxdr1123/ZeroBot v1.6.6
github.com/wdvxdr1123/ZeroBot v1.6.7
gitlab.com/gomidi/midi/v2 v2.0.25
golang.org/x/image v0.3.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Coloured-glaze/gg v1.3.4 h1:l31zIF/HaVwkzjrj+A56RGQoSKyKuR1IWtIrqXGFStI=
github.com/Coloured-glaze/gg v1.3.4/go.mod h1:Ih5NLNNDHOy3RJbB0EPqGTreIzq/H02TGThIagh8HJg=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230107074849-392b0b10b149 h1:luwPT3dGLRYLjRfLlz4Uo1r4Us7UkrCL9tz9cFUuuJs=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230107074849-392b0b10b149/go.mod h1:Kg0LSMN9KjqbAGzcd4T6xvL/hvlnzlOU/nWJ63we3oo=
github.com/FloatTech/floatbox v0.0.0-20230107061309-dcd5c0012dd3 h1:LSuKljwLeoW/jFrIprWpD0yUT0YUTKqukK/fPrS5BGw=
github.com/FloatTech/floatbox v0.0.0-20230107061309-dcd5c0012dd3/go.mod h1:/k2zxRJtAJ17w9fSpc7xf2QjPDTUBmqhBsOGyHVyX0U=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230109125955-02d902ce0951 h1:xTK3g4IAbVRMifOzDzVfgHtJP7FGJ6liVg6RUvUstB8=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230109125955-02d902ce0951/go.mod h1:gAV8BewrVPCc7VptvbRsCbuYEx33QQbMfajaO6NgsU0=
github.com/FloatTech/floatbox v0.0.0-20230109123116-c544925718fe h1:PJi6gIqSTnepn1wmGA/AeU4M+HPOiIUgQMYYfuK59YI=
github.com/FloatTech/floatbox v0.0.0-20230109123116-c544925718fe/go.mod h1:0+3iDgifrdiEoEsmYe+yiAlUQcmnudhTiiBdSkam2XY=
github.com/FloatTech/rendercard v0.0.3 h1:eKOKlmotlDq/YbAcJKe0GMzBjGTsT5eSsyEfjT+hy10=
github.com/FloatTech/rendercard v0.0.3/go.mod h1:FwwKoWpv1fW7AZ1mwBVWF8GCH9mEqYYIE9LzdmozCZQ=
github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk=
github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw=
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
github.com/FloatTech/zbpctrl v1.5.3-0.20221210051848-740ab7bd6ec3 h1:dxARTVta2i48OOYa0xMRzWTO0lr6bM4M6JmQWLkHdNE=
github.com/FloatTech/zbpctrl v1.5.3-0.20221210051848-740ab7bd6ec3/go.mod h1:KFfMTzItP5usfnUYs7cFWjk89dzjtdO1eI+B1BVQNig=
github.com/FloatTech/zbputils v1.6.1-0.20230107061700-dadcf8500e7a h1:nv3+ss6kID+nn1ZC5e3DJC59aHljeXPb0Tx0xMpbmQI=
github.com/FloatTech/zbputils v1.6.1-0.20230107061700-dadcf8500e7a/go.mod h1:cbIXoOF4IEBSUiI175cpfiC7XV70+TMQpbLGuTrRoLA=
github.com/FloatTech/zbpctrl v1.5.3-0.20230109124217-41203036b80a h1:O+GS8J1pEM4E8q05EcopHBK6kfIr0BJJ/cHuPa8yWLM=
github.com/FloatTech/zbpctrl v1.5.3-0.20230109124217-41203036b80a/go.mod h1:UT3bZNKMF/+r2XzSvIVXWudnTgmWsQrRPOJ3bmBfjFI=
github.com/FloatTech/zbputils v1.6.1-0.20230109125328-bf06bab484de h1:8QYhYSqcnLOoyyW6tbduO/oBbTD99VayTDFhrjLM4BQ=
github.com/FloatTech/zbputils v1.6.1-0.20230109125328-bf06bab484de/go.mod h1:PJrojrMeyK11qAy6mYQbRgM1OaPqvh7/PIiBCDNFt4c=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA=
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
Expand Down Expand Up @@ -54,10 +54,10 @@ github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b h1:Zt3pFQditAdWTHCO
github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
github.com/fumiama/go-base16384 v1.6.1 h1:4yb4JgmBJDnQtq3XGXXdLrVwEnRpjhMUt4eAcsNeA30=
github.com/fumiama/go-base16384 v1.6.1/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
github.com/fumiama/go-registry v0.2.5-0.20221121111817-44b0846bdce6 h1:rCvtE5Qcj6HVJICbDC7SOmIl4QnkAKSNt5/wJ/AO4wo=
github.com/fumiama/go-registry v0.2.5-0.20221121111817-44b0846bdce6/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o=
github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
github.com/fumiama/go-registry v0.2.5 h1:Y6tnHnTThQPv7E4JPM2vBprU+4EQw/LEDO33HCmxgI4=
github.com/fumiama/go-registry v0.2.5/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
Expand Down Expand Up @@ -188,8 +188,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
github.com/wdvxdr1123/ZeroBot v1.6.6 h1:UG5OKh3POo6JID4I3/Qab94aQFgqP2rA5nIswwHke58=
github.com/wdvxdr1123/ZeroBot v1.6.6/go.mod h1:T5kD5vLi/YxL/fyDOCOaawi96LRBdJjcXh2CIjDyFfg=
github.com/wdvxdr1123/ZeroBot v1.6.7 h1:JK29W0j9k82X4FdGcbgqP5IFikUYMaUysUOIALGfQrw=
github.com/wdvxdr1123/ZeroBot v1.6.7/go.mod h1:T5kD5vLi/YxL/fyDOCOaawi96LRBdJjcXh2CIjDyFfg=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
Expand Down
7 changes: 5 additions & 2 deletions kanban/banner.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package kanban

// Version ...
var Version = "v1.6.1-beta4"

// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version v1.6.1-beta3 - 2022-12-26 13:45:09 +0800 CST\n" +
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.\n" +
"* Version " + Version + " - 2023-01-09 21:14:12 +0800 CST\n" +
"* Copyright © 2020 - 2023 FloatTech. All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
5 changes: 4 additions & 1 deletion kanban/gen/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import (

const banner = `package kanban
// Version ...
var Version = "%s"
// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version %s - %s\n" +
"* Version " + Version + " - %s\n" +
"* Copyright © 2020 - %d FloatTech. All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
`
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import (

_ "github.com/FloatTech/ZeroBot-Plugin/plugin/manager" // 群管

_ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复

_ "github.com/FloatTech/zbputils/job" // 定时指令触发器

// ^^^^ //
Expand Down Expand Up @@ -140,7 +138,8 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame

// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西

// ^^^^ //
// ^^^^^^^^^^^^^^ //
Expand Down
14 changes: 3 additions & 11 deletions plugin/ai_reply/ai_tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
defaultttsindexkey = -2905
)

var replyModes = [...]string{"青云客", "小爱", "ChatGPT"}
var replyModes = [...]string{"青云客", "小爱"}

func setReplyMode(ctx *zero.Ctx, name string) error {
gid := ctx.Event.GroupID
Expand All @@ -62,25 +62,17 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff))
}

var chats *aireply.ChatGPT

func getReplyMode(ctx *zero.Ctx) aireply.AIReply {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if ok {
switch m.GetData(gid) & 0xff {
case 0:
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
case 1:
if m.GetData(gid)&0xff == 1 {
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
case 2:
if chats != nil {
return chats
}
}
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
}
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
}
Expand Down
102 changes: 1 addition & 101 deletions plugin/ai_reply/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
package aireply

import (
"os"
"strconv"
"time"

"github.com/FloatTech/AnimeAPI/aireply"
"github.com/FloatTech/AnimeAPI/chatgpt"
"github.com/FloatTech/AnimeAPI/tts/genshin"
"github.com/FloatTech/floatbox/binary"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
Expand All @@ -35,7 +31,7 @@ func init() { // 插件主体
enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "人工智能回复",
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱|ChatGPT]\n- 设置 ChatGPT SessionToken xxx\n- 设置 ChatGPT UA xxx\n- 设置 ChatGPT CF xxx\n- 重置ChatGPT连接",
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
PrivateDataFolder: "aireply",
})

Expand Down Expand Up @@ -63,102 +59,6 @@ func init() { // 插件主体
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
})

chatgptfile := enr.DataFolder() + "chatgpt.txt"
uafile := enr.DataFolder() + "ua.txt"
cffile := enr.DataFolder() + "cf.txt"
cfg := &chatgpt.Config{
RefreshInterval: time.Hour,
Timeout: time.Minute,
}
data, err := os.ReadFile(chatgptfile)
if err == nil {
cfg.SessionToken = binary.BytesToString(data)
data, err = os.ReadFile(uafile)
if err == nil {
cfg.UA = binary.BytesToString(data)
data, err = os.ReadFile(cffile)
if err == nil {
cfg.CFClearance = binary.BytesToString(data)
}
}
}
chats = aireply.NewChatGPT(cfg)
go func() {
for range time.NewTicker(time.Hour).C {
if chats == nil || cfg.SessionToken == "" {
continue
}
err := os.WriteFile(chatgptfile, binary.StringToBytes(cfg.SessionToken), 0644)
if err != nil {
logrus.Warnln("[aireply] 保存 chatgpt session token 到", chatgptfile, "失败:", err)
}
}
}()

enr.OnRegex(`^设置\s*ChatGPT\s*SessionToken\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
token := ctx.State["regex_matched"].([]string)[1]
f, err := os.Create(chatgptfile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
defer f.Close()
_, err = f.WriteString(token)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
cfg.SessionToken = token
ctx.SendChain(message.Text("设置成功"))
})

enr.OnRegex(`^设置\s*ChatGPT\s*UA\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
ua := ctx.State["regex_matched"].([]string)[1]
f, err := os.Create(uafile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
defer f.Close()
_, err = f.WriteString(ua)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
cfg.UA = ua
ctx.SendChain(message.Text("设置成功"))
})

enr.OnRegex(`^设置\s*ChatGPT\s*CF\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cf := ctx.State["regex_matched"].([]string)[1]
f, err := os.Create(cffile)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
defer f.Close()
_, err = f.WriteString(cf)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
cfg.CFClearance = cf
ctx.SendChain(message.Text("设置成功"))
})

enr.OnFullMatch("重置ChatGPT连接").SetBlock(true).Handle(func(ctx *zero.Ctx) {
if chats == nil {
ctx.SendChain(message.Text("ERROR: chats 为空"))
return
}
err := chats.Reset(ctx.Event.UserID)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功"))
})

ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
Expand Down

0 comments on commit 8ca7196

Please sign in to comment.