diff --git a/README.md b/README.md index 6db823e8d5..14b66946c6 100644 --- a/README.md +++ b/README.md @@ -220,8 +220,15 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ... - [x] coser - **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" ` - [x] 小说[xxx] -- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"` - - [x] 骂他[@xxx]|骂他[qq号] +- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao"` + - [x] 骂他[@xxx]|骂他[qq号] (停用) + - [x] 骂我 (停用) + - [x] 哄我 + - [x] 渣我 + - [x] 来碗绿茶 + - [x] 发个朋友圈 + - [x] 来碗毒鸡汤 + - [x] 讲个段子 - **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"` - [x] 讲个笑话[@xxx]|讲个笑话[qq号] - **TODO...** diff --git a/main.go b/main.go index 83ab6666e5..55ca7fcc20 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,6 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse" // 骂人 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石 @@ -43,6 +42,7 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定 // b站相关 diff --git a/plugin_chat/chat.go b/plugin_chat/chat.go index 64cea2f6f9..41e944113e 100644 --- a/plugin_chat/chat.go +++ b/plugin_chat/chat.go @@ -117,7 +117,7 @@ func init() { // 插件主体 key := ctx.MessageString() val := *kimomap[key] text := val[rand.Intn(len(val))] - ctx.SendChain(message.At(ctx.Event.UserID), message.Text(text)) + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) }) }) } diff --git a/plugin_coser/coser.go b/plugin_coser/coser.go index e296fb562c..e981765f91 100644 --- a/plugin_coser/coser.go +++ b/plugin_coser/coser.go @@ -43,16 +43,16 @@ func init() { text := gjson.Get(helper.BytesToString(data), "data.Title").String() m = append(m, message.CustomNode( - zero.BotConfig.NickName[0], - ctx.Event.SelfID, + ctx.Event.Sender.NickName, + ctx.Event.UserID, text, )) gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool { imgcq := `[CQ:image,file=` + value.String() + `]` m = append(m, message.CustomNode( - zero.BotConfig.NickName[0], - ctx.Event.SelfID, + ctx.Event.Sender.NickName, + ctx.Event.UserID, imgcq), ) return true diff --git a/plugin_curse/curse.go b/plugin_curse/curse.go deleted file mode 100644 index e60ee4dbf1..0000000000 --- a/plugin_curse/curse.go +++ /dev/null @@ -1,54 +0,0 @@ -package curse - -import ( - "time" - - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/extension/rate" - "github.com/wdvxdr1123/ZeroBot/message" - "github.com/wdvxdr1123/ZeroBot/utils/helper" - - "github.com/FloatTech/ZeroBot-Plugin/control" - "github.com/FloatTech/ZeroBot-Plugin/utils/math" - "github.com/FloatTech/ZeroBot-Plugin/utils/web" -) - -const ( - ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" - curseURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn" -) - -var ( - engine = control.Register("curse", &control.Options{ - DisableOnDefault: false, - Help: "骂人\n" + - "- 骂他[@xxx]|骂他[qq号]\n", - }) - limit = rate.NewManager(time.Minute, 20) -) - -func init() { - engine.OnPrefix("骂我").SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) { - if !limit.Load(ctx.Event.GroupID).Acquire() { - return - } - data, err := web.ReqWith(curseURL, "GET", "", ua) - if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) - return - } - ctx.SendChain(message.At(ctx.Event.UserID), message.Text(helper.BytesToString(data))) - }) - engine.OnRegex(`^骂他.*?(\d+)`, zero.OnlyGroup).SetBlock(true).SetPriority(40). - Handle(func(ctx *zero.Ctx) { - if !limit.Load(ctx.Event.GroupID).Acquire() { - return - } - data, err := web.ReqWith(curseURL, "GET", "", ua) - if err != nil { - ctx.SendChain(message.Text("ERROR:", err)) - return - } - ctx.SendChain(message.At(math.Str2Int64(ctx.State["regex_matched"].([]string)[1])), message.Text(helper.BytesToString(data))) - }) -} diff --git a/plugin_shadiao/caihongpi.go b/plugin_shadiao/caihongpi.go new file mode 100644 index 0000000000..50107e86ed --- /dev/null +++ b/plugin_shadiao/caihongpi.go @@ -0,0 +1,22 @@ +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/utils/web" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" +) + +func init() { + engine.OnFullMatch("哄我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(chpURL, "GET", chpReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data))) + }) +} diff --git a/plugin_shadiao/dujitang.go b/plugin_shadiao/dujitang.go new file mode 100644 index 0000000000..f1e6eec5c5 --- /dev/null +++ b/plugin_shadiao/dujitang.go @@ -0,0 +1,22 @@ +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/utils/web" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" +) + +func init() { + engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(duURL, "GET", duReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data))) + }) +} diff --git a/plugin_shadiao/pengyouquan.go b/plugin_shadiao/pengyouquan.go new file mode 100644 index 0000000000..636d30ed32 --- /dev/null +++ b/plugin_shadiao/pengyouquan.go @@ -0,0 +1,22 @@ +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/utils/web" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" +) + +func init() { + engine.OnFullMatch("发个朋友圈").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data))) + }) +} diff --git a/plugin_shadiao/shadiao.go b/plugin_shadiao/shadiao.go new file mode 100644 index 0000000000..ec4ab9760a --- /dev/null +++ b/plugin_shadiao/shadiao.go @@ -0,0 +1,35 @@ +// Package shadiao 来源于 https://shadiao.app/# 的接口 +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/control" + "github.com/wdvxdr1123/ZeroBot/extension/rate" + "time" +) + +const ( + chpURL = "https://chp.shadiao.app/api.php" + duURL = "https://du.shadiao.app/api.php" + pyqURL = "https://pyq.shadiao.app/api.php" + yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi" + chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0" + ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1" + zuanURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn" + ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" + chpReferer = "https://chp.shadiao.app/" + duReferer = "https://du.shadiao.app/" + pyqReferer = "https://pyq.shadiao.app/" + yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app" + loveliveReferer = "https://lovelive.tools/" + zuanReferer = "https://zuanbot.com/" + prio = 10 +) + +var ( + engine = control.Register("curse", &control.Options{ + DisableOnDefault: false, + Help: "沙雕app\n" + + "- 骂他[@xxx]|骂他[qq号](停用)\n- 骂我(停用)\n- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子", + }) + limit = rate.NewManager(time.Minute, 60) +) diff --git a/plugin_shadiao/sweetnothings.go b/plugin_shadiao/sweetnothings.go new file mode 100644 index 0000000000..427afacfc2 --- /dev/null +++ b/plugin_shadiao/sweetnothings.go @@ -0,0 +1,37 @@ +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/utils/web" + "github.com/tidwall/gjson" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" +) + +func init() { + engine.OnFullMatch("来碗绿茶").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + text := gjson.Get(helper.BytesToString(data), "returnObj.content").String() + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) + }) + + engine.OnFullMatch("渣我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + text := gjson.Get(helper.BytesToString(data), "returnObj.content").String() + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) + }) +} diff --git a/plugin_shadiao/yduanzi.go b/plugin_shadiao/yduanzi.go new file mode 100644 index 0000000000..801e2e2c83 --- /dev/null +++ b/plugin_shadiao/yduanzi.go @@ -0,0 +1,26 @@ +package shadiao + +import ( + "github.com/FloatTech/ZeroBot-Plugin/utils/web" + "github.com/tidwall/gjson" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" + "github.com/wdvxdr1123/ZeroBot/utils/helper" + "strings" +) + +func init() { + engine.OnFullMatch("讲个段子").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + text := gjson.Get(helper.BytesToString(data), "duanzi").String() + text = strings.Replace(text, "
", "\n", -1) + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text)) + }) +} diff --git a/plugin_shadiao/zuan.go b/plugin_shadiao/zuan.go new file mode 100644 index 0000000000..28ee3f5eab --- /dev/null +++ b/plugin_shadiao/zuan.go @@ -0,0 +1,29 @@ +package shadiao + +func init() { + /* + engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(zuanURL, "GET", zuanReferer, ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data))) + }) + engine.OnRegex(`^骂他.*?(\d+)`, zero.OnlyGroup).SetBlock(true).SetPriority(40). + Handle(func(ctx *zero.Ctx) { + if !limit.Load(ctx.Event.GroupID).Acquire() { + return + } + data, err := web.ReqWith(zuanURL, "GET", "", ua) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.At(math.Str2Int64(ctx.State["regex_matched"].([]string)[1])), message.Text(helper.BytesToString(data))) + }) + */ +}