优化代码 (#501)

This commit is contained in:
方柳煜 2022-11-17 12:08:12 +08:00 committed by GitHub
parent 9f37962d22
commit a55f28c006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 20 deletions

View File

@ -259,19 +259,7 @@ func init() {
listName := ctx.State["regex_matched"].([]string)[5] listName := ctx.State["regex_matched"].([]string)[5]
ctx.SendChain(message.Text("正在校验歌单信息,请稍等")) ctx.SendChain(message.Text("正在校验歌单信息,请稍等"))
// 是否存在该歌单 // 是否存在该歌单
filelist, err := getlist(cfg.MusicPath) if file.IsNotExist(cfg.MusicPath + listName) {
if err != nil {
ctx.SendChain(message.Text(serviceErr, "获取歌单列表ERROR:", err))
return
}
ok := true
for _, listinfo := range filelist {
if listName == listinfo.Name {
ok = false
break
}
}
if ok {
ctx.SendChain(message.Text("歌单不存在,是否创建?(是/否)")) ctx.SendChain(message.Text("歌单不存在,是否创建?(是/否)"))
next := zero.NewFutureEvent("message", 999, false, zero.OnlyGroup, zero.RegexRule(`(是|否)`), ctx.CheckSession()) next := zero.NewFutureEvent("message", 999, false, zero.OnlyGroup, zero.RegexRule(`(是|否)`), ctx.CheckSession())
recv, cancel := next.Repeat() recv, cancel := next.Repeat()
@ -296,12 +284,13 @@ func init() {
break break
} }
} }
err = os.MkdirAll(cfg.MusicPath+listName, 0755) err := os.MkdirAll(cfg.MusicPath+listName, 0755)
if err != nil { if err != nil {
ctx.SendChain(message.Text(serviceErr, err)) ctx.SendChain(message.Text(serviceErr, err))
return return
} }
} }
ctx.SendChain(message.Text("开始下载歌曲,需要一定时间下载,请稍等"))
listID, err := strconv.ParseInt(keyword, 10, 64) listID, err := strconv.ParseInt(keyword, 10, 64)
if err == nil { if err == nil {
err = downloadlist(listID, cfg.MusicPath+listName+"/") err = downloadlist(listID, cfg.MusicPath+listName+"/")

View File

@ -471,7 +471,7 @@ func init() {
fiancee := ctx.State["regex_matched"].([]string) fiancee := ctx.State["regex_matched"].([]string)
gay, _ := strconv.ParseInt(fiancee[2]+fiancee[3], 10, 64) gay, _ := strconv.ParseInt(fiancee[2]+fiancee[3], 10, 64)
if gay == uid { if gay == uid {
ctx.Send(message.ReplyWithMessage(message.At(uid), message.Text("[qqwife]你想给自己买什么礼物呢?"))) ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.At(uid), message.Text("[qqwife]你想给自己买什么礼物呢?")))
return return
} }
// 获取CD // 获取CD
@ -504,12 +504,12 @@ func init() {
// 计算钱对应的好感值 // 计算钱对应的好感值
newFavor := 1 newFavor := 1
if favor > 50 { if favor > 50 {
newFavor += moneyToFavor % 10 // 礼物厌倦 newFavor = moneyToFavor % 10 // 礼物厌倦
} else { } else {
newFavor += rand.Intn(moneyToFavor) newFavor += rand.Intn(moneyToFavor)
} }
// 随机对方心情 // 随机对方心情
mood := rand.Intn(5) mood := rand.Intn(2)
if mood == 0 { if mood == 0 {
newFavor = -newFavor newFavor = -newFavor
} }

View File

@ -279,14 +279,14 @@ func init() { // 插件主体
"————————————————————\n" + "————————————————————\n" +
"- 文心对联 [上联]\n" + "- 文心对联 [上联]\n" +
"————————————————————\n" + "————————————————————\n" +
"- 文心问答 [问题]" + "- 文心问答 [问题]\n" +
"————————————————————\n" + "————————————————————\n" +
"- 文心补全 [带“_”的填空题]\n" + "- 文心补全 [带“_”的填空题]\n" +
"————————————————————\n" + "————————————————————\n" +
"- 文心自定义 [prompt]\n" + "- 文心自定义 [prompt]\n\n" +
"prompt: [问题描述] [问题类型]:[题目] [解答类型]:[解题必带内容]\n" + "prompt: [问题描述] [问题类型]:[题目] [解答类型]:[解题必带内容]\n" +
"指令示例:\n" + "指令示例:\n" +
"文心自定义 请写出下面这道题的解题过程。\\n题目:养殖场养鸭376只,养鸡的只数比鸭多258只,这个养殖场一共养鸭和鸡多少只?\\n解\n" + "文心自定义 请写出下面这道题的解题过程。\\n题目:养殖场养鸭376只,养鸡的只数比鸭多258只,这个养殖场一共养鸭和鸡多少只?\\n解\n\n" +
"文心自定义 1+1=?\n" + "文心自定义 1+1=?\n" +
"文心自定义 歌曲名:大风车转啊转\\n歌词", "文心自定义 歌曲名:大风车转啊转\\n歌词",
}).ApplySingle(single.New( }).ApplySingle(single.New(