优化输出

This commit is contained in:
源文雨 2022-09-10 13:24:15 +08:00
parent 3351450d88
commit ca7ac08808
3 changed files with 16 additions and 16 deletions

View File

@ -38,17 +38,17 @@ func init() {
s := ahsaitts.NewSpeaker() s := ahsaitts.NewSpeaker()
err := s.SetName(ctx.State["ahsainame"].(string)) err := s.SetName(ctx.State["ahsainame"].(string))
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
u, err := s.Speak(ctx.State["ahsaitext"].(string)) u, err := s.Speak(ctx.State["ahsaitext"].(string))
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
err = ahsaitts.SaveOggToFile(u, ahsaiFile) err = ahsaitts.SaveOggToFile(u, ahsaiFile)
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + ahsaiFile)) ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + ahsaiFile))

View File

@ -65,7 +65,7 @@ func init() {
_, _ = engine.GetLazyData("bilibili.db", false) _, _ = engine.GetLazyData("bilibili.db", false)
vdb, err = initializeVup(engine.DataFolder() + "bilibili.db") vdb, err = initializeVup(engine.DataFolder() + "bilibili.db")
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return false return false
} }
return true return true
@ -277,7 +277,7 @@ func init() {
} }
u, err := getMemberCard(id) u, err := getMemberCard(id)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
var danmaku danmakusuki var danmaku danmakusuki
@ -289,12 +289,12 @@ func init() {
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
data, err := web.RequestDataWith(client, fmt.Sprintf(danmakuAPI, id, pagenum), "GET", "", web.RandUA()) data, err := web.RequestDataWith(client, fmt.Sprintf(danmakuAPI, id, pagenum), "GET", "", web.RandUA())
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
err = json.Unmarshal(data, &danmaku) err = json.Unmarshal(data, &danmaku)
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
today := time.Now().Format("20060102150415") today := time.Now().Format("20060102150415")
@ -306,12 +306,12 @@ func init() {
if path.Ext(u.Face) != ".webp" { if path.Ext(u.Face) != ".webp" {
err = initFacePic(facePath, u.Face) err = initFacePic(facePath, u.Face)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
back, err = gg.LoadImage(facePath) back, err = gg.LoadImage(facePath)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
back = img.Size(back, backX, backY).Im back = img.Size(back, backX, backY).Im
@ -320,10 +320,10 @@ func init() {
fontSize := 50.0 fontSize := 50.0
_, err = file.GetLazyData(text.BoldFontFile, true) _, err = file.GetLazyData(text.BoldFontFile, true)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
} }
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil { if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
dz, h := canvas.MeasureString("好") dz, h := canvas.MeasureString("好")
@ -342,7 +342,7 @@ func init() {
canvas.Clear() canvas.Clear()
canvas.SetColor(color.Black) canvas.SetColor(color.Black)
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil { if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
facestart := 100 facestart := 100
@ -372,12 +372,12 @@ func init() {
if path.Ext(item.Channel.FaceURL) != ".webp" { if path.Ext(item.Channel.FaceURL) != ".webp" {
err = initFacePic(facePath, item.Channel.FaceURL) err = initFacePic(facePath, item.Channel.FaceURL)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
back, err = gg.LoadImage(facePath) back, err = gg.LoadImage(facePath)
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
back = img.Size(back, backX, backY).Im back = img.Size(back, backX, backY).Im
@ -518,7 +518,7 @@ func init() {
_, err = writer.WriteTo(nim, f) _, err = writer.WriteTo(nim, f)
_ = f.Close() _ = f.Close()
if err != nil { if err != nil {
ctx.SendChain(message.Text("ERROR:", err)) ctx.SendChain(message.Text("ERROR: ", err))
return return
} }
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile)) ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))

View File

@ -20,7 +20,7 @@ func init() {
msg := []string{ctx.State["regex_matched"].([]string)[2]} msg := []string{ctx.State["regex_matched"].([]string)[2]}
data, err := tl.Translate(msg[0]) data, err := tl.Translate(msg[0])
if err != nil { if err != nil {
ctx.SendChain(message.Text("Error:", data)) ctx.SendChain(message.Text("ERROR: ", data))
return return
} }
ctx.SendChain(message.Text(data)) ctx.SendChain(message.Text(data))