(picFile string, uid int64)
| 324 | } |
| 325 | |
| 326 | func initPic(picFile string, uid int64) (avatar []byte, err error) { |
| 327 | defer process.SleepAbout1sTo2s() |
| 328 | avatar, err = web.GetData("https://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640") |
| 329 | if err != nil { |
| 330 | return |
| 331 | } |
| 332 | if file.IsExist(picFile) { |
| 333 | return |
| 334 | } |
| 335 | url, err := bilibili.GetRealURL(backgroundURL) |
| 336 | if err == nil { |
| 337 | data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil) |
| 338 | if err == nil { |
| 339 | return avatar, os.WriteFile(picFile, data, 0644) |
| 340 | } |
| 341 | } |
| 342 | // 获取网络图片失败,使用本地已有的图片 |
| 343 | log.Error("[score:get online img error]:", err) |
| 344 | return avatar, copyImage(picFile) |
| 345 | } |
| 346 | |
| 347 | // 使用"file:"发送图片失败后,改用base64发送 |
| 348 | func trySendImage(filePath string, ctx *zero.Ctx) { |
no test coverage detected