添加拟声鸟类型和马丁路德骂人语录 (#227)

*  mockingbird添加类型

*  添加马丁路德骂人语录

Co-authored-by: haibaraguo <haibaraguo@yeahka.com>
This commit is contained in:
himawari 2022-05-14 11:32:25 +08:00 committed by GitHub
parent a7387dcf22
commit af2fe727fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 9 deletions

View File

@ -796,12 +796,26 @@ print("run[CQ:image,file="+j["img"]+"]")
</details>
<details>
<summary>签到得分</summary>
<summary>签到得分</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/score"`
- [x] 签到
- [x] 获得签到背景[@xxx] | 获得签到背景
- [x] 获得签到背景[@xxx] | 获得签到背景
</details>
<details>
<summary>沙雕app</summary>
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao"`
- [x] 哄我
- [x] 渣我
- [x] 来碗绿茶
- [x] 发个朋友圈
- [x] 来碗毒鸡汤
- [x] 讲个段子
- [x] 马丁路德骂我
</details>
<details>

View File

@ -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

View File

@ -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))
})
}

View File

@ -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}
)