Skip to content

戳一戳消息的处理似乎有bug #94

@yp05327

Description

@yp05327

log:

fail: Lagrange.Core.Internal.Context.EventContext[955647033]
      Handle trpc.msg.olpush.OlPushService.MsgPush server packet failed
      Lagrange.Core.Exceptions.LagrangeException: An error occurred while processing the incoming event
       ---> System.Collections.Generic.KeyNotFoundException: The given key 'action_str' was not present in the dictionary.
         at Lagrange.Core.Internal.Logic.Processors.GroupNudgeProcessor.Handle(BotContext context, MsgType msgType, Int32 subType, PushMessageEvent msgEvt, Nullable`1 content) + 0x413
         at Lagrange.Core.Internal.Logic.PushLogic.<Incoming>d__3.MoveNext() + 0x26d
      --- End of stack trace from previous location ---
         at Lagrange.Core.Internal.Context.EventContext.<HandleIncomingEvent>d__6.MoveNext() + 0x111
         --- End of inner exception stack trace ---
         at Lagrange.Core.Internal.Context.EventContext.<HandleIncomingEvent>d__6.MoveNext() + 0x29f
      --- End of stack trace from previous location ---
         at Lagrange.Core.Internal.Context.EventContext.<HandleServerPacket>d__9.MoveNext() + 0xed

缺少字段action_str


结论:
部分戳一戳没有action_str,用的是alt_str1


可能的修复:

diff --git a/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs
index 602d264..2bdba73 100644
--- a/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs
+++ b/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs
@@ -24,10 +24,14 @@ internal class GroupNudgeProcessor : MsgPushProcessorBase
 
         if (greyTip.GeneralGrayTip.BusiType == 12) // poke
         {
+            if (!@params.TryGetValue("action_str", out var actionStr))
+            {
+                _ = @params.TryGetValue("alt_str1", out actionStr);
+            }
             context.EventInvoker.PostEvent(new BotGroupNudgeEvent(
                 groupUin,
                 long.Parse(@params["uin_str1"]),
-                @params["action_str"],
+                actionStr ?? string.Empty,
                 @params["action_img_url"],
                 long.Parse(@params["uin_str2"]),
                 @params["suffix_str"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions