HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.32k stars 605 forks source link

功能调用统计可视化 调用出错 #1488

Closed PatchouliTIS closed 1 year ago

PatchouliTIS commented 1 year ago

在群内使用 功能调用统计 时,出现报错:

  File "/home/patchy/zhenxun_bot-0.1.6.7/plugins/statistics/statistics_handle.py", line 166, in _
    name = name.group_name if group else str(event.group_id)
UnboundLocalError: local variable 'name' referenced before assignment

定位到 statistics_handle.py 第166行

//....
 day_index = data["day_index"]
    data = data[arg][key]
    if _type == "group":
        group = await GroupInfo.filter(group_id=event.group_id).first()
       >>> name = name.group_name if group else str(event.group_id) <<<
    else:
        name = event.sender.card or event.sender.nickname
    img = await generate_statistics_img(data, arg, name, plugin, day_index)
    await statistics.send(image(b64=img))

变量声明位置有些问题。

超级用户单独调用全局统计的话是没有问题的。

PatchouliTIS commented 1 year ago

bot 使用的v0.1.6.7

HibiKier commented 1 year ago

换成最新的试试