MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / initPic

Function initPic

plugin/score/sign_in.go:326–345  ·  view source on GitHub ↗
(picFile string, uid int64)

Source from the content-addressed store, hash-verified

324}
325
326func 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发送
348func trySendImage(filePath string, ctx *zero.Ctx) {

Callers 4

drawScore16Function · 0.85
drawScore15Function · 0.85
drawScore17Function · 0.85
drawScore17b2Function · 0.85

Calls 1

copyImageFunction · 0.85

Tested by

no test coverage detected