ZeroBot-Plugin/plugin_shadiao/yduanzi.go
himawari a3b5a226ac
增加沙雕app一系列接口 (#91)
* feat:添加沙雕app一系列api

* fix: 修个文案

* fix:修改等级

* fix:好孩子不能骂人

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2021-12-24 12:32:26 +08:00

27 lines
755 B
Go

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, "<br>", "\n", -1)
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
}