Compare commits

...

20 Commits

Author SHA1 Message Date
源文雨
0357405cdf 🐛 心跳 2023-07-28 16:29:56 +08:00
源文雨
7f264964c2 🔖 v1.7.2 2023-07-28 13:59:33 +08:00
源文雨
c8dcdbb0b2 world: 一大波优化与功能更新
- fix #441
- 优化wsserver解析
- 完善 ctx.this 相关函数
- 自动已读: Config 的 MarkMessage
2023-07-28 13:56:48 +08:00
Jiang-Red
ebcd3cdef2 fix shindan (#706) 2023-07-27 13:20:51 +08:00
Jiang-Red
eb43f84d34 fix title (#705) 2023-07-23 00:41:00 +08:00
莫思潋
5931e03c00 *update help command (#703) 2023-07-18 23:46:28 +08:00
Jiang-Red
aaf659f6d4 fix runcode (#702)
* fix runcode

* fix permission
2023-07-17 22:57:58 +08:00
weigui404
f4add826ff Update README.md (#701) 2023-07-16 15:50:45 +08:00
Jiang-Red
0d8157e2f8 修复反向ws顺便禁用新版ci的某个功能 (#700) 2023-07-13 14:23:25 +08:00
alexskim
283667cfe5 修多功能抽签不刷新列表bug (#693) 2023-06-13 11:46:06 +08:00
源文雨
6403614fa8 🐛 fix control cache 2023-05-14 23:49:46 +08:00
源文雨
bdcb833217 🐛 fix control cache 2023-05-09 13:35:50 +08:00
源文雨
278d7e0cf9 🔖 v1.7.1 2023-04-30 13:52:25 +08:00
源文雨
821f8d4949 update wife 2023-04-30 13:51:25 +08:00
源文雨
436838d2f8 fix 2023-04-22 14:53:32 +08:00
源文雨
30301f1aba 🦙请求改POST 2023-04-22 14:40:35 +08:00
源文雨
df1d71b9b2 remove 🦙 reply 2023-04-21 14:49:34 +08:00
源文雨
0315718ab7 优化 2023-04-20 01:14:32 +08:00
源文雨
971c179227 优化 2023-04-19 23:26:15 +08:00
源文雨
1c0270fda0 thesarus add 🦙 2023-04-19 23:07:43 +08:00
18 changed files with 178 additions and 95 deletions

View File

@@ -18,7 +18,7 @@ linters:
fast: false
enable:
- bodyclose
- depguard
#- depguard
- dogsled
- errcheck
- exportloopref

View File

@@ -17,7 +17,7 @@
[![go](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin)
[![onebot](https://img.shields.io/badge/onebot-v11-black?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://t.me/zerobotplugin)
[![zerobot](https://img.shields.io/badge/zerobot-v1.6.11-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot)
[![zerobot](https://img.shields.io/badge/zerobot-v1.7.2-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot)
[![license](https://img.shields.io/github/license/FloatTech/ZeroBot-Plugin.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
[![tencent-qq](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
[![telegram](https://img.shields.io/badge/Telegram-click%20me-informational?style=flat-square&logo=telegram)](https://t.me/zerobotplugin)
@@ -42,9 +42,10 @@
## 命令行参数
> `[]`代表是可选参数
```bash
zerobot [-h] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&]
zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s config.json] [-l latency] [-r ringlen] [-x max process time] [qq1 qq2 qq3 ...] [&]
```
- **-h**: 显示帮助
- **-m**: 不自动标记消息为已读
- **-n nickname**: 设置默认昵称,默认为`椛椛`
- **-t token**: 设置`AccessToken`,默认为空
- **-u url**: 设置`Url`,默认为`ws://127.0.0.1:6700`
@@ -62,27 +63,17 @@ zerobot [-h] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w] [-c|s
默认配置文件格式如下。当选择从配置文件加载时,将忽略相应命令行参数。
```json
{
"zero": {
"nickname": [
"椛椛",
"ATRI",
"atri",
"亚托莉",
"アトリ"
],
"command_prefix": "/",
"super_users": [],
"ring_len": 4096,
"latency": 233000000,
"max_process_time": 240000000000
},
"ws": [
{
"Url": "ws://127.0.0.1:6700",
"AccessToken": ""
}
],
"wss": null
"zero": {
"nickname": ["椛椛", "ATRI", "atri", "亚托莉", "アトリ"],
"command_prefix": "/",
"super_users": [],
"ring_len": 4096,
"latency": 233000000,
"max_process_time": 240000000000,
"mark_message": true
},
"ws": [{ "Url": "ws://127.0.0.1:6700", "AccessToken": "" }],
"wss": null
}
```
@@ -1295,7 +1286,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] steam[添加|删除]订阅xxxxx
- [x] steam查订阅
- [x] steam查订阅
- [x] steam绑定 api key xxxxxxx

View File

@@ -79,7 +79,7 @@ func init() {
logrus.Warnln("VT100设置失败, 将以无色模式输出")
}
err = setConsoleTitle("ZeroBot-Blugin " + banner.Version + " " + banner.Copyright)
err = setConsoleTitle("ZeroBot-Plugin " + banner.Version + " " + banner.Copyright)
if err != nil {
panic(err)
}

2
data

Submodule data updated: 074abee575...9cab8a7bae

10
go.mod
View File

@@ -4,15 +4,15 @@ go 1.20
require (
github.com/Baidu-AIP/golang-sdk v1.1.1
github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da
github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92
github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944
github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
github.com/FloatTech/sqlite v1.6.2
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67
github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf
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
@@ -24,7 +24,6 @@ require (
github.com/fumiama/go-base16384 v1.6.4
github.com/fumiama/go-registry v0.2.6
github.com/fumiama/gotracemoe v0.0.3
github.com/fumiama/imgsz v0.0.2
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
@@ -38,7 +37,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.11
github.com/wdvxdr1123/ZeroBot v1.7.4
gitlab.com/gomidi/midi/v2 v2.0.25
golang.org/x/image v0.3.0
golang.org/x/sys v0.4.0
@@ -52,6 +51,7 @@ require (
github.com/faiface/beep v1.1.0 // indirect
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
github.com/fumiama/gofastTEA v0.0.10 // indirect
github.com/fumiama/imgsz v0.0.2 // indirect
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect

16
go.sum
View File

@@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da h1:QyH0zpWt3YspNNfZ+5f8+QStvtmxrzld/DoocKjF+rc=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230409024643-f25135dee0da/go.mod h1:UnCPjtpIzpNBZ02yeGYp+oYVxgoi5aF2yAK2bkOVxtI=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92 h1:B4IaLEhnXdr7oqszneri6ykdHggL2GvPUueBB5WxYVQ=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230724165034-a3cf504fab92/go.mod h1:fWJ5hx1ggDmLyLldO53Go97zc1JpWnDpsC5qeTOcaVw=
github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944 h1:/eQoMa6Aj3coF5F7yhzZe1+SzX6SItul7MW8//pl18o=
github.com/FloatTech/floatbox v0.0.0-20230331064925-9af336a84944/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI=
github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU=
@@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.2 h1:FytbExjpvYalZxxITtmSenHiPGLPUvlz47LY/P0SCC
github.com/FloatTech/sqlite v1.6.2/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.20230411055601-7cdff751dd67 h1:KGfXWryE3VGFDC8Z6661d/7xm8oLNPpFB5ODb7DqYJc=
github.com/FloatTech/zbpctrl v1.5.3-0.20230411055601-7cdff751dd67/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0=
github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2 h1:Dx64RjcbxhsOHinykOPAlYqvPd9tE375IQrWqlNmDXs=
github.com/FloatTech/zbputils v1.6.2-0.20230411114057-4c71136244b2/go.mod h1:m3IW5z7vLMNgNtVNUfcYtOF1du6PnjckifdRK2hVjA0=
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380 h1:qmwoT8xVaND01aCdwy+5/j6z490nehQWZAVyTBN8ahU=
github.com/FloatTech/zbpctrl v1.5.3-0.20230514154630-b74e6fcca380/go.mod h1:gkGC1C1eEUd/Ld/ja68zas5j2ZktIZCdnj2FMaM+Au0=
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf h1:PwH9aMnmN+m204cVIqUrI3e7nsdQi/IGW012Fjzb1bs=
github.com/FloatTech/zbputils v1.6.2-0.20230728081122-94d4d957f3bf/go.mod h1:JRnGR7EGeEQgxOs+c0rZAhrS9Es2BTcGHdIDHXIPRzQ=
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=
@@ -203,8 +203,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.11 h1:44Wr6CsCtWlFensK5IhuVCWkosdRw0rA8SygVD8DgoI=
github.com/wdvxdr1123/ZeroBot v1.6.11/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
github.com/wdvxdr1123/ZeroBot v1.7.4 h1:+148rELpf/FCDW2EuvKqpb9bNKcwKRtoh16s2sIb5SE=
github.com/wdvxdr1123/ZeroBot v1.7.4/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
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=

View File

@@ -3,13 +3,13 @@
package banner
// Version ...
var Version = "v1.7.1-beta3"
var Version = "v1.7.2"
// Copyright ...
var Copyright = "© 2020 - 2023 FloatTech"
// Banner ...
var Banner = "* OneBot + ZeroBot + Golang\n" +
"* Version " + Version + " - 2023-04-19 11:36:16 +0800 CST\n" +
"* Version " + Version + " - 2023-07-28 13:58:50 +0800 CST\n" +
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"

View File

@@ -231,6 +231,7 @@ func init() {
late := flag.Uint("l", 233, "Response latency (ms).")
rsz := flag.Uint("r", 4096, "Receiving buffer ring size.")
maxpt := flag.Uint("x", 4, "Max process time (min).")
markmsg := flag.Bool("m", false, "Don't mark message as read automatically")
flag.Parse()
@@ -290,6 +291,7 @@ func init() {
RingLen: *rsz,
Latency: time.Duration(*late) * time.Millisecond,
MaxProcessTime: time.Duration(*maxpt) * time.Minute,
MarkMessage: !*markmsg,
Driver: []zero.Driver{config.W[0]},
}
@@ -313,7 +315,7 @@ func main() {
rand.Seed(time.Now().UnixNano()) //nolint: staticcheck
}
// 帮助
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
zero.OnFullMatchGroup([]string{"help", "/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(banner.Banner, "\n管理发送\"/服务列表\"查看 bot 功能\n发送\"/用法name\"查看功能用法"))
})

View File

@@ -70,7 +70,7 @@ func init() {
if err := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]).Manager.DoBlock(uid); err == nil {
t := time.Now().Unix()
cache.Set(uid, struct{}{})
ctx.SetGroupBan(gid, uid, int64(bandur.Minutes()))
ctx.SetThisGroupBan(uid, int64(bandur.Minutes()))
ctx.SendChain(message.Text("检测到违禁词, 已封禁/屏蔽", bandur))
db.Lock()
defer db.Unlock()

View File

@@ -68,7 +68,7 @@ func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) {
bantime = group.BANTime * 60
}
// 执行禁言
ctx.SetGroupBan(ctx.Event.GroupID, ctx.Event.UserID, bantime)
ctx.SetThisGroupBan(ctx.Event.UserID, bantime)
}
// 查看是否开启撤回提示
if group.DMRemind {

View File

@@ -53,7 +53,8 @@ var (
func init() {
en.OnFullMatchGroup([]string{"抽签列表", "刷新抽签列表"}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
lotsList, err := getList() // 刷新列表
var err error
lotsList, err = getList() // 刷新列表
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return

View File

@@ -39,8 +39,8 @@ func init() {
userid := ctx.Event.UserID
username := ctx.CardOrNickName(userid)
data := (storage)(c.GetData(-su))
groupname := ctx.GetThisGroupInfo(true).Name
groupid := ctx.Event.GroupID
groupname := ctx.GetGroupInfo(groupid, true).Name
logrus.Info("[event]收到来自[", username, "](", userid, ")的群聊邀请,群:[", groupname, "](", groupid, ")")
if data.isinviteon() || (!data.ismasteroff() && zero.SuperUserPermission(ctx)) {
ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "")

View File

@@ -527,7 +527,7 @@ func getlist(pathOfMusic string) (list []listinfo, err error) {
// 遍历群文件
func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileURL string) {
filesOfGroup := ctx.GetThisGroupRootFiles(ctx.Event.GroupID)
filesOfGroup := ctx.GetThisGroupRootFiles()
files := filesOfGroup.Get("files").Array()
folders := filesOfGroup.Get("folders").Array()
// 遍历当前目录的文件名

View File

@@ -95,13 +95,11 @@ func init() { // 插件主体
// 升为管理
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupAdmin(
ctx.Event.GroupID,
ctx.SetThisGroupAdmin(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
true,
)
nickname := ctx.GetGroupMemberInfo( // 被升为管理的人的昵称
ctx.Event.GroupID,
nickname := ctx.GetThisGroupMemberInfo( // 被升为管理的人的昵称
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被升为管理的人的qq
false,
).Get("nickname").Str
@@ -110,13 +108,11 @@ func init() { // 插件主体
// 取消管理
engine.OnRegex(`^取消管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupAdmin(
ctx.Event.GroupID,
ctx.SetThisGroupAdmin(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
false,
)
nickname := ctx.GetGroupMemberInfo( // 被取消管理的人的昵称
ctx.Event.GroupID,
nickname := ctx.GetThisGroupMemberInfo( // 被取消管理的人的昵称
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被取消管理的人的qq
false,
).Get("nickname").Str
@@ -125,13 +121,11 @@ func init() { // 插件主体
// 踢出群聊
engine.OnRegex(`^踢出群聊.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupKick(
ctx.Event.GroupID,
ctx.SetThisGroupKick(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
false,
)
nickname := ctx.GetGroupMemberInfo( // 被踢出群聊的人的昵称
ctx.Event.GroupID,
nickname := ctx.GetThisGroupMemberInfo( // 被踢出群聊的人的昵称
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被踢出群聊的人的qq
false,
).Get("nickname").Str
@@ -148,19 +142,13 @@ func init() { // 插件主体
// 开启全体禁言
engine.OnRegex(`^开启全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupWholeBan(
ctx.Event.GroupID,
true,
)
ctx.SetThisGroupWholeBan(true)
ctx.SendChain(message.Text("全员自闭开始~"))
})
// 解除全员禁言
engine.OnRegex(`^解除全员禁言$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupWholeBan(
ctx.Event.GroupID,
false,
)
ctx.SetThisGroupWholeBan(false)
ctx.SendChain(message.Text("全员自闭结束~"))
})
// 禁言
@@ -180,8 +168,7 @@ func init() { // 插件主体
if duration >= 43200 {
duration = 43199 // qq禁言最大时长为一个月
}
ctx.SetGroupBan(
ctx.Event.GroupID,
ctx.SetThisGroupBan(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要禁言的人的qq
duration*60, // 要禁言的时间(分钟)
)
@@ -190,8 +177,7 @@ func init() { // 插件主体
// 解除禁言
engine.OnRegex(`^解除禁言.*?(\d+)`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SetGroupBan(
ctx.Event.GroupID,
ctx.SetThisGroupBan(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 要解除禁言的人的qq
0,
)
@@ -214,8 +200,7 @@ func init() { // 插件主体
if duration >= 43200 {
duration = 43199 // qq禁言最大时长为一个月
}
ctx.SetGroupBan(
ctx.Event.GroupID,
ctx.SetThisGroupBan(
ctx.Event.UserID,
duration*60, // 要自闭的时间(分钟)
)
@@ -228,8 +213,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("名字太长啦!"))
return
}
ctx.SetGroupCard(
ctx.Event.GroupID,
ctx.SetThisGroupCard(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群名片的人
ctx.State["regex_matched"].([]string)[2], // 修改成的群名片
)
@@ -246,8 +230,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("头衔太长啦!"))
return
}
ctx.SetGroupSpecialTitle(
ctx.Event.GroupID,
ctx.SetThisGroupSpecialTitle(
math.Str2Int64(ctx.State["regex_matched"].([]string)[1]), // 被修改群头衔的人
sptitle, // 修改成的群头衔
)
@@ -264,8 +247,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("头衔太长啦!"))
return
}
ctx.SetGroupSpecialTitle(
ctx.Event.GroupID,
ctx.SetThisGroupSpecialTitle(
ctx.Event.UserID, // 被修改群头衔的人
sptitle, // 修改成的群头衔
)
@@ -445,7 +427,7 @@ func init() { // 插件主体
case <-time.After(time.Minute):
cancel()
ctx.SendChain(message.Text("拜拜啦~"))
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
ctx.SetThisGroupKick(uid, false)
case <-recv:
cancel()
ctx.SendChain(message.Text("答对啦~"))
@@ -594,7 +576,7 @@ func init() { // 插件主体
if ok {
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", true, "")
process.SleepAbout1sTo2s()
ctx.SetGroupCard(ctx.Event.GroupID, ctx.Event.UserID, ghun)
ctx.SetThisGroupCard(ctx.Event.UserID, ghun)
} else {
ctx.SetGroupAddRequest(ctx.Event.Flag, "add", false, reason)
}
@@ -618,7 +600,7 @@ func init() { // 插件主体
}
})
engine.OnCommand("精华列表", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
list := ctx.GetGroupEssenceMessageList(ctx.Event.GroupID).Array()
list := ctx.GetThisGroupEssenceMessageList().Array()
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("本群精华列表:"))}
n := len(list)
if n > 30 {
@@ -675,7 +657,7 @@ func welcometocq(ctx *zero.Ctx, welcome string) string {
at := "[CQ:at,qq=" + uid + "]" // at用户
avatar := "[CQ:image,file=" + "http://q4.qlogo.cn/g?b=qq&nk=" + uid + "&s=640]" // 用户头像
gid := strconv.FormatInt(ctx.Event.GroupID, 10) // 群id
groupname := ctx.GetGroupInfo(ctx.Event.GroupID, true).Name // 群名
groupname := ctx.GetThisGroupInfo(true).Name // 群名
cqstring := strings.ReplaceAll(welcome, "{at}", at)
cqstring = strings.ReplaceAll(cqstring, "{nickname}", nickname)
cqstring = strings.ReplaceAll(cqstring, "{avatar}", avatar)

View File

@@ -12,7 +12,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
)
var ro = runoob.NewRunOOB("b6365362a90ac2ac7098ba52c13e352b")
var ro = runoob.NewRunOOB("066417defb80d038228de76ec581a50a")
func init() {
control.Register("runcode", &ctrl.Options[*zero.Ctx]{
@@ -59,7 +59,7 @@ func init() {
} else {
// 运行成功
output = cutTooLong(strings.Trim(output, "\n"))
if israw {
if israw && zero.AdminPermission(ctx) {
ctx.SendChain(message.Text(output))
} else {
ctx.SendChain(

View File

@@ -5,10 +5,17 @@ import (
"bytes"
"encoding/json"
"math/rand"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/process"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/fumiama/jieba"
@@ -22,10 +29,33 @@ func init() {
engine := control.Register("thesaurus", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "词典匹配回复",
Help: "- 切换[kimo|傲娇|可爱]词库\n- 设置词库触发概率0.x (0<x<9)",
Help: "- 切换[kimo|傲娇|可爱|🦙]词库\n- 设置词库触发概率0.x (0<x<9)",
PublicDataFolder: "Chat",
})
engine.OnRegex(`^切换(kimo|傲娇|可爱)词库$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
alpacafolder := engine.DataFolder() + "alpaca/"
err := os.MkdirAll(alpacafolder, 0755)
if err != nil {
panic(err)
}
alpacapifile := alpacafolder + "api.txt"
alpacapiurl := ""
if file.IsExist(alpacapifile) {
data, err := os.ReadFile(alpacapifile)
if err != nil {
panic(err)
}
alpacapiurl = binary.BytesToString(data)
}
alpacatokenfile := alpacafolder + "token.txt"
alpacatoken := ""
if file.IsExist(alpacatokenfile) {
data, err := os.ReadFile(alpacatokenfile)
if err != nil {
panic(err)
}
alpacatoken = binary.BytesToString(data)
}
engine.OnRegex(`^切换(kimo|傲娇|可爱|🦙)词库$`, zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
if !ok {
ctx.SendChain(message.Text("ERROR: 找不到 manager"))
@@ -44,6 +74,8 @@ func init() {
t = tDERE
case "可爱":
t = tKAWA
case "🦙":
t = tALPACA
}
err := c.SetData(gid, (d&^3)|t)
if err != nil {
@@ -76,6 +108,24 @@ func init() {
}
ctx.SendChain(message.Text("成功!"))
})
engine.OnRegex(`^设置🦙API地址\s*(http.*)\s*$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).Handle(func(ctx *zero.Ctx) {
alpacapiurl = ctx.State["regex_matched"].([]string)[1]
err := os.WriteFile(alpacapifile, binary.StringToBytes(alpacapiurl), 0644)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功!"))
})
engine.OnRegex(`^设置🦙token\s*([0-9a-f]{112})\s*$`, zero.SuperUserPermission, zero.OnlyPrivate).SetBlock(true).Handle(func(ctx *zero.Ctx) {
alpacatoken = ctx.State["regex_matched"].([]string)[1]
err := os.WriteFile(alpacatokenfile, binary.StringToBytes(alpacatoken), 0644)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Text("成功!"))
})
go func() {
data, err := engine.GetLazyData("dict.txt", false)
if err != nil {
@@ -128,6 +178,57 @@ func init() {
engine.OnMessage(canmatch(tKAWA), match(chatListK, seg)).
SetBlock(false).
Handle(randreply(sm.K))
engine.OnMessage(canmatch(tALPACA), func(ctx *zero.Ctx) bool {
return alpacapiurl != "" && alpacatoken != ""
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
if msg != "" {
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply", "POST",
func(r *http.Request) error {
r.Header.Set("Authorization", alpacatoken)
return nil
}, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) {
_ = json.NewEncoder(writer).Encode(&[]alpacamsg{{
Name: ctx.CardOrNickName(ctx.Event.UserID),
Message: msg,
}})
})))
if err != nil {
logrus.Warnln("[chat] 🦙 err:", err)
return
}
type reply struct {
ID int
Msg string
}
m := reply{}
err = json.Unmarshal(data, &m)
if err != nil {
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
return
}
for i := 0; i < 60; i++ {
time.Sleep(time.Second * 4)
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/get?id="+strconv.Itoa(m.ID), "GET",
func(r *http.Request) error {
r.Header.Set("Authorization", alpacatoken)
return nil
}, nil)
if err != nil {
continue
}
err = json.Unmarshal(data, &m)
if err != nil {
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
return
}
if len(m.Msg) > 0 {
ctx.Send(message.Text(m.Msg))
}
return
}
}
})
}()
}
@@ -138,10 +239,16 @@ type simai struct {
K map[string][]string `yaml:"可爱"`
}
type alpacamsg struct {
Name string
Message string
}
const (
tKIMO = iota
tDERE
tKAWA
tALPACA
)
func match(l []string, seg *jieba.Segmenter) zero.Rule {

View File

@@ -44,7 +44,7 @@ func init() {
var secondname string
if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" {
qq, _ := strconv.ParseInt(ctx.Event.Message[1].Data["qq"], 10, 64)
secondname = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").Str
secondname = ctx.GetThisGroupMemberInfo(qq, false).Get("nickname").Str
}
name = ctx.Event.Sender.NickName
var text string

View File

@@ -12,7 +12,7 @@
"0409": {
"identity": {
"name": "ZeroBot-Plugin",
"version": "1.7.1.1812"
"version": "1.7.2.1831"
},
"description": "",
"minimum-os": "vista",
@@ -36,23 +36,23 @@
"#1": {
"0000": {
"fixed": {
"file_version": "1.7.1.1812",
"product_version": "v1.7.1-beta3",
"timestamp": "2023-04-19T11:36:27+08:00"
"file_version": "1.7.2.1831",
"product_version": "v1.7.2",
"timestamp": "2023-07-28T13:59:16+08:00"
},
"info": {
"0409": {
"Comments": "OneBot plugins based on ZeroBot",
"CompanyName": "FloatTech",
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
"FileVersion": "1.7.1.1812",
"FileVersion": "1.7.2.1831",
"InternalName": "",
"LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.",
"LegalTrademarks": "",
"OriginalFilename": "ZBP.EXE",
"PrivateBuild": "",
"ProductName": "ZeroBot-Plugin",
"ProductVersion": "v1.7.1-beta3",
"ProductVersion": "v1.7.2",
"SpecialBuild": ""
}
}