mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
维护guessmusic和qqwife插件 (#385)
* 优化error输出,新增猜歌结束后分享歌曲 * 添加反并发,防止被多娶 * Update main.go
This commit is contained in:
parent
941d6d2884
commit
0943023a19
@ -526,7 +526,8 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("游戏已取消,猜歌答案是\n", answerString)))
|
||||
message.Text("游戏已取消,猜歌答案是\n", answerString, "\n\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
}
|
||||
ctx.Send(
|
||||
@ -557,21 +558,24 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对歌曲名了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对歌曲名了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
case strings.Contains(musicInfo[1], answer) || strings.EqualFold(musicInfo[1], answer):
|
||||
wait.Stop()
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对歌手名了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对歌手名了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
case strings.Contains(musicAlia, answer) || strings.EqualFold(musicAlia, answer):
|
||||
wait.Stop()
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对出处了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对出处了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
default:
|
||||
musicCount++
|
||||
@ -589,7 +593,8 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("次数到了,没能猜出来。答案是\n", answerString)))
|
||||
message.Text("次数到了,没能猜出来。答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
default:
|
||||
wait.Reset(40 * time.Second)
|
||||
@ -752,7 +757,11 @@ func getListMusic(listID, pathOfMusic string) (musicName string, err error) {
|
||||
musicURL := "http://music.163.com/song/media/outer/url?id=" + strconv.Itoa(musicID)
|
||||
response, err := http.Head(musicURL)
|
||||
if err != nil {
|
||||
err = errors.Errorf("下载音乐失败, ERROR: %s", err)
|
||||
if strings.Contains(err.Error(), "404") {
|
||||
err = errors.Errorf("歌曲丢失, 可能歌曲已下架或者登录状态已过期。\n可尝试重新登录排除后者问题。")
|
||||
} else {
|
||||
err = errors.Errorf("下载音乐失败, ERROR: %s", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
_ = response.Body.Close()
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
|
||||
// 数据库
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
@ -290,7 +291,16 @@ func init() {
|
||||
"- 娶群友\n- 群老婆列表\n" +
|
||||
"--------------------------------\n以下技能每人只能三选一\n CD12H,不跨天刷新\n--------------------------------\n" +
|
||||
"- (娶|嫁)@对方QQ\n- 当[对方Q号|@对方QQ]的小三\n- 闹离婚",
|
||||
})
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("民政局门口排长队了!你们一个个来,别着急......"),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db"
|
||||
// 如果数据库不存在则下载
|
||||
|
||||
Loading…
Reference in New Issue
Block a user