Skip to content

Commit

Permalink
fix: aireply: ent->enr & update README & optimize bilibili match (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
shudorcl committed Dec 9, 2022
1 parent df83ffc commit 5d9ac50
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,12 @@ print("run[CQ:image,file="+j["img"]+"]")

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

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

- [x] 设置 ChatGPT SessionToken xxx

- 注册和获取token可以参见这两篇文章:[注册](https://www.cnblogs.com/ranxi169/p/16954797.html) [获取token](https://juejin.cn/post/7174088036035067917)

</details>

## 三种使用方法,推荐第一种
Expand Down
7 changes: 4 additions & 3 deletions plugin/ai_reply/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func init() { // 插件主体
}
ctx.SendChain(message.Text("设置成功"))
})
chatgptfile := ent.DataFolder() + "chatgpt.txt"
chatgptfile := enr.DataFolder() + "chatgpt.txt"
cfg := &chatgpt.Config{
UA: chatgpt.UA,
RefreshInterval: time.Hour,
Expand All @@ -178,7 +178,7 @@ func init() { // 插件主体
}
}
}()
ent.OnRegex(`^设置\s*ChatGPT\s*SessionToken\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
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 {
Expand All @@ -199,7 +199,8 @@ func init() { // 插件主体
})
ctx.SendChain(message.Text("设置成功"))
})
ent.OnFullMatch("重置ChatGPT连接").SetBlock(true).Handle(func(ctx *zero.Ctx) {
enr.OnFullMatch("重置ChatGPT连接").SetBlock(true).Handle(func(ctx *zero.Ctx) {
chats.Reset(ctx.Event.UserID)
ctx.SendChain(message.Text("成功"))
})
}
14 changes: 7 additions & 7 deletions plugin/bilibili/bilibilipush.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func init() {
dbfile := dbpath + "push.db"
bdb = initializePush(dbfile)

en.OnRegex(`^添加b站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`^添加[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func init() {
}
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
})
en.OnRegex(`^取消b站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`^取消[B|b]站订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
Expand All @@ -90,7 +90,7 @@ func init() {
}
ctx.SendChain(message.Text("已取消" + name + "的订阅"))
})
en.OnRegex(`^取消b站动态订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`^取消[B|b]站动态订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
name, err := getName(buid)
if err != nil {
Expand All @@ -107,7 +107,7 @@ func init() {
}
ctx.SendChain(message.Text("已取消" + name + "的动态订阅"))
})
en.OnRegex(`^取消b站直播订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`^取消[B|b]站直播订阅\s?(.{1,25})$`, zero.UserOrGrpAdmin, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
gid := ctx.Event.GroupID
if gid == 0 {
Expand All @@ -124,13 +124,13 @@ func init() {
}
ctx.SendChain(message.Text("已取消" + name + "的直播订阅"))
})
en.OnFullMatch("b站推送列表", zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`^[B|b]站推送列表$`, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
bpl := bdb.getAllPushByGroup(gid)
msg := "--------b站推送列表--------"
msg := "--------B站推送列表--------"
for _, v := range bpl {
if _, ok := upMap[v.BilibiliUID]; !ok {
bdb.updateAllUp()
Expand Down Expand Up @@ -158,7 +158,7 @@ func init() {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
})
en.OnFullMatch("拉取b站推送").SetBlock(true).Handle(func(ctx *zero.Ctx) {
en.OnRegex(`拉取[B|b]站推送$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
err := sendDynamic(ctx)
if err != nil {
ctx.SendPrivateMessage(ctx.Event.UserID, message.Text("Error: bilibilipush,", err))
Expand Down
6 changes: 3 additions & 3 deletions plugin/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("那我就不手下留情了~"))
})
// 修改名片
engine.OnRegex(`^修改名片.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
engine.OnRegex(`^修改名片.*(\d+).*\s+(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if len(ctx.State["regex_matched"].([]string)[2]) > 60 {
ctx.SendChain(message.Text("名字太长啦!"))
Expand All @@ -236,7 +236,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯!已经修改了"))
})
// 修改头衔
engine.OnRegex(`^修改头衔.*?(\d+).*?\s(.*)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
engine.OnRegex(`^修改头衔.*(\d+).*\s+(.*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if len(ctx.State["regex_matched"].([]string)[1]) > 18 {
ctx.SendChain(message.Text("头衔太长啦!"))
Expand All @@ -250,7 +250,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("嗯!已经修改了"))
})
// 申请头衔
engine.OnRegex(`^申请头衔(.*)`, zero.OnlyGroup).SetBlock(true).
engine.OnRegex(`^申请头衔\s+(.*)$`, zero.OnlyGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
if len(ctx.State["regex_matched"].([]string)[1]) > 18 {
ctx.SendChain(message.Text("头衔太长啦!"))
Expand Down

0 comments on commit 5d9ac50

Please sign in to comment.