diff --git a/README.md b/README.md index 7ef32fa7..78e8d6c2 100644 --- a/README.md +++ b/README.md @@ -796,12 +796,26 @@ print("run[CQ:image,file="+j["img"]+"]")
- ​签到得分 + 签到得分 -`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"` +`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/score"` - [x] 签到 - - [x] 获得签到背景[@xxx] | 获得签到背景 + - [x] 获得签到背景[@xxx] | 获得签到背景 + +
+
+ 沙雕app + +`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao"` + +- [x] 哄我 +- [x] 渣我 +- [x] 来碗绿茶 +- [x] 发个朋友圈 +- [x] 来碗毒鸡汤 +- [x] 讲个段子 +- [x] 马丁路德骂我
diff --git a/plugin/ai_reply/ai_tts.go b/plugin/ai_reply/ai_tts.go index 000706ef..fb7fbd5d 100644 --- a/plugin/ai_reply/ai_tts.go +++ b/plugin/ai_reply/ai_tts.go @@ -45,16 +45,17 @@ func init() { "百度度逍遥": baidutts.NewBaiduTTS(3), "百度度丫丫": baidutts.NewBaiduTTS(4), "拟声鸟阿梓": nil, + "拟声鸟文静": nil, "拟声鸟药水哥": nil, }, - l: []string{"拟声鸟阿梓", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"}, + l: []string{"拟声鸟阿梓", "拟声鸟文静", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"}, } engine := control.Register(ttsServiceName, &control.Options{ DisableOnDefault: true, Help: "语音回复(包括拟声鸟和百度)\n" + "- @Bot 任意文本(任意一句话回复)\n" + - "- 设置语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" + - "- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n", + "- 设置语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" + + "- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n", }) engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser). Handle(func(ctx *zero.Ctx) { @@ -65,9 +66,10 @@ func init() { ctx.SendChain(message.Text("ERROR:", err)) return } + var reply string if tts != nil { rec, err := tts.Speak(ctx.Event.UserID, func() string { - reply := r.TalkPlain(msg, zero.BotConfig.NickName[0]) + reply = r.TalkPlain(msg, zero.BotConfig.NickName[0]) reply = re.ReplaceAllStringFunc(reply, func(s string) string { f, err := strconv.ParseFloat(s, 64) if err != nil { @@ -81,6 +83,8 @@ func init() { }) if err == nil { ctx.SendChain(message.Record(rec)) + } else { + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply)) } } }) @@ -113,10 +117,14 @@ func (t *ttsInstances) new(name string) (ts tts.TTS, err error) { t.Lock() ts, err = mockingbird.NewMockingBirdTTS(0) t.Unlock() - case "拟声鸟药水哥": + case "拟声鸟文静": t.Lock() ts, err = mockingbird.NewMockingBirdTTS(1) t.Unlock() + case "拟声鸟药水哥": + t.Lock() + ts, err = mockingbird.NewMockingBirdTTS(2) + t.Unlock() } } return diff --git a/plugin/shadiao/ergofabulous.go b/plugin/shadiao/ergofabulous.go new file mode 100644 index 00000000..a3ede4a3 --- /dev/null +++ b/plugin/shadiao/ergofabulous.go @@ -0,0 +1,24 @@ +package shadiao + +import ( + "github.com/FloatTech/zbputils/ctxext" + "github.com/antchfx/htmlquery" + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +func init() { + engine.OnFullMatch("马丁路德骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) { + doc, err := htmlquery.LoadURL(ergofabulousURL) + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + node, err := htmlquery.Query(doc, "//main[@role=\"main\"]/p[@class=\"larger\"]/text()") + if err != nil { + ctx.SendChain(message.Text("ERROR:", err)) + return + } + ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(node.Data)) + }) +} diff --git a/plugin/shadiao/shadiao.go b/plugin/shadiao/shadiao.go index 414c3b0c..10a27b02 100644 --- a/plugin/shadiao/shadiao.go +++ b/plugin/shadiao/shadiao.go @@ -17,6 +17,7 @@ const ( 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" + ergofabulousURL = "https://ergofabulous.org/luther/?" ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" sdReferer = "https://api.shadiao.app/" yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app" @@ -27,7 +28,7 @@ var ( engine = control.Register("shadiao", &control.Options{ DisableOnDefault: false, Help: "沙雕app\n" + - "- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子", + "- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子\n- 马丁路德骂我\n", }) sdMap = map[string]string{"哄我": chpURL, "来碗毒鸡汤": duURL, "发个朋友圈": pyqURL} )