-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
ZeroBot-Plugin/plugin/manager/timer/timer.go
Lines 64 to 74 in 5cd46b3
| var ctx *zero.Ctx | |
| if ts.SelfID != 0 { | |
| ctx = zero.GetBot(ts.SelfID) | |
| } else { | |
| zero.RangeBot(func(id int64, c *zero.Ctx) bool { | |
| ctx = c | |
| ts.SelfID = id | |
| return false | |
| }) | |
| } | |
| eid, err := c.cron.AddFunc(ts.Cron, func() { ts.sendmsg(ts.GrpID, ctx) }) |
该ctx的获取于66行,而这导致该值只会在注册命令时获取,因此在重启机器人后,由cron触发的第74行的sendMsg代码中的ctx将为空,这将导致整个机器人崩溃。在发送前重新获取ctx可避免该问题。不知道作者是否有别的修复建议
发生异常: panic
"runtime error: invalid memory address or nil pointer dereference"
Stack:
4 0x00000000009d247a in github.com/FloatTech/ZeroBot-Plugin/plugin/manager/timer.(*Timer).sendmsg
at [c:/Code/go/ZeroBot-Plugin/plugin/manager/timer/msg.go:9]()
5 0x00000000009d6a88 in github.com/FloatTech/ZeroBot-Plugin/plugin/manager/timer.(*Clock).RegisterTimer.func2
at [c:/Code/go/ZeroBot-Plugin/plugin/manager/timer/timer.go:75]()
6 0x0000000000941f1f in github.com/fumiama/cron.FuncJob.Run
at [C:/Users/AN/go/pkg/mod/github.com/fumiama/cron]()@v1.3.0/cron.go:135
7 0x0000000000944108 in github.com/fumiama/cron.(*Cron).startJob.func1
at [C:/Users/AN/go/pkg/mod/github.com/fumiama/cron]()@v1.3.0/cron.go:361
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels