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

Function drawstatus

plugin/aifalse/main.go:147–544  ·  view source on GitHub ↗
(m *ctrl.Control[*zero.Ctx], uid int64, botname string, botrunstatus string)

Source from the content-addressed store, hash-verified

145}
146
147func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string, botrunstatus string) (sendimg image.Image, err error) {
148 diskstate, err := diskstate()
149 if err != nil {
150 return
151 }
152 diskcardh := 40 + (20+50)*len(diskstate) + 40 - 20
153
154 moreinfo, err := moreinfo(m)
155 if err != nil {
156 return
157 }
158 moreinfocardh := 30 + (20+32*72/96)*len(moreinfo) + 30 - 20
159
160 basicstate, err := basicstate()
161 if err != nil {
162 return
163 }
164
165 dldata := (*[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata))))
166 if dldata == (*[]byte)(nil) || uintptr(time.Since(boottime).Hours()/24) >= atomic.LoadUintptr(&bgcount) {
167 url, err1 := bilibili.GetRealURL(backgroundURL)
168 if err1 != nil {
169 return nil, err1
170 }
171 data, err1 := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
172 if err1 != nil {
173 return nil, err1
174 }
175 atomic.AddUintptr(&bgcount, 1)
176 atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)), unsafe.Pointer(&data))
177 dldata = &data
178 }
179 data := *dldata
180
181 back, _, err := image.Decode(bytes.NewReader(data))
182 if err != nil {
183 return
184 }
185
186 data, err = web.GetData("https://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640")
187 if err != nil {
188 return
189 }
190 avatar, _, err := image.Decode(bytes.NewReader(data))
191 if err != nil {
192 return
193 }
194 avatarf := factory.Size(avatar, 200, 200)
195
196 fontbyte, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, true)
197 if err != nil {
198 return
199 }
200
201 canvas := gg.NewContext(1280, 70+250+40+380+diskcardh+40+moreinfocardh+40+70)
202
203 bh, bw, ch, cw := float64(back.Bounds().Dy()), float64(back.Bounds().Dx()), float64(canvas.H()), float64(canvas.W())
204

Callers 1

initFunction · 0.85

Calls 8

diskstateFunction · 0.85
moreinfoFunction · 0.85
basicstateFunction · 0.85
colorswitchFunction · 0.85
fontcolorswitchFunction · 0.85
botruntimeFunction · 0.85
botstatusFunction · 0.85
slice2colorFunction · 0.85

Tested by

no test coverage detected