Skip to content

Commit

Permalink
维护guessmusic和qqwife插件 (#385)
Browse files Browse the repository at this point in the history
* 优化error输出,新增猜歌结束后分享歌曲

* 添加反并发,防止被多娶

* Update main.go
  • Loading branch information
fangliuyu authored Aug 26, 2022
1 parent 941d6d2 commit 0943023
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
21 changes: 15 additions & 6 deletions plugin/guessmusic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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++
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 11 additions & 1 deletion plugin/qqwife/qqmapwife.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
// 如果数据库不存在则下载
Expand Down

0 comments on commit 0943023

Please sign in to comment.