@@ -254,6 +254,19 @@ func truncatecopy(params map[string]any) map[string]any {
254254}
255255
256256func logev (ctx * zero.Ctx ) {
257+ gid := ctx .Event .GroupID
258+ if gid == 0 {
259+ gid = - ctx .Event .UserID
260+ }
261+ ev := togobaev (ctx .Event )
262+ if ev == nil {
263+ return
264+ }
265+ data , _ := json .Marshal (ev )
266+ logrus .Debugln ("[chat] agent" , gid , "add ev:" , binary .BytesToString (data ))
267+ AgentOf (ctx .Event .SelfID , "aichat" ).AddEvent (gid , ev )
268+ ctx .State [zero .StateKeyPrefixKeep + "_chat_ag_hooked__" ] = struct {}{}
269+
257270 vevent .HookCtxCaller (ctx , vevent .NewAPICallerReturnHook (
258271 ctx , func (req zero.APIRequest , rsp zero.APIResponse , _ error ) {
259272 gid := ctx .Event .GroupID
@@ -284,18 +297,6 @@ func logev(ctx *zero.Ctx) {
284297 })
285298 }),
286299 )
287- ctx .State [zero .StateKeyPrefixKeep + "_chat_ag_hooked__" ] = struct {}{}
288- gid := ctx .Event .GroupID
289- if gid == 0 {
290- gid = - ctx .Event .UserID
291- }
292- ev := togobaev (ctx .Event )
293- if ev == nil {
294- return
295- }
296- data , _ := json .Marshal (ev )
297- logrus .Debugln ("[chat] agent" , gid , "add ev:" , binary .BytesToString (data ))
298- AgentOf (ctx .Event .SelfID , "aichat" ).AddEvent (gid , ev )
299300}
300301
301302func init () {
0 commit comments