/// <summary> /// 构造用 /// </summary> /// <param name="jo"></param> public Event(JObject jo) { EMsg = new EventMsg(jo); if (jo.TryGetValue("EventName", out var EventName)) { var en = EventName.ToString(); this.EType = en switch { "ON_EVENT_GROUP_ADMIN" => EventType.ON_EVENT_GROUP_ADMIN, "ON_EVENT_GROUP_ADMINSYSNOTIFY" => EventType.ON_EVENT_GROUP_ADMINSYSNOTIFY, "ON_EVENT_GROUP_SHUT" => EventType.ON_EVENT_GROUP_SHUT, "ON_EVENT_GROUP_EXIT" => EventType.ON_EVENT_GROUP_EXIT, "ON_EVENT_GROUP_EXIT_SUCC" => EventType.ON_EVENT_GROUP_EXIT_SUCC, "ON_EVENT_GROUP_JOIN" => EventType.ON_EVENT_GROUP_JOIN, "ON_EVENT_FRIEND_ADD" => EventType.ON_EVENT_FRIEND_ADD, "ON_EVENT_GROUP_REVOKE" => EventType.ON_EVENT_GROUP_REVOKE, _ => EventType.ON_EVENT_NULL_REF }; } else { throw new Exception(EC.E01); } if (jo.TryGetValue("EventData", out var EventData)) { JObject jed = JObject.Parse(EventData.ToString()); this.Data = EventName.ToString() switch { "ON_EVENT_GROUP_ADMIN" => jed.ToObject <ON_EVENT_GROUP_ADMIN>(), "ON_EVENT_GROUP_ADMINSYSNOTIFY" => jed.ToObject <ON_EVENT_GROUP_ADMINSYSNOTIFY>(), "ON_EVENT_GROUP_SHUT" => jed.ToObject <ON_EVENT_GROUP_SHUT>(), "ON_EVENT_GROUP_EXIT" => jed.ToObject <ON_EVENT_GROUP_EXIT>(), "ON_EVENT_GROUP_EXIT_SUCC" => jed.ToObject <ON_EVENT_GROUP_EXIT_SUCC>(), "ON_EVENT_GROUP_JOIN" => jed.ToObject <ON_EVENT_GROUP_JOIN>(), "ON_EVENT_FRIEND_ADD" => jed.ToObject <ON_EVENT_FRIEND_ADD>(), "ON_EVENT_GROUP_REVOKE" => jed.ToObject <ON_EVENT_GROUP_REVOKE>(), _ => null }; } else { throw new Exception(EC.E02); } }
/// <summary> /// 构造用 /// </summary> /// <param name="jo"></param> public EventMsg(JObject jo) { if (jo.TryGetValue("EventMsg", out var EventMsg)) { var em = JObject.Parse(EventMsg.ToString()); em.TryGetValue("FromUin", out var FromUin); this.FromUser = FromUin?.ToObject <long>() ?? 0; em.TryGetValue("ToUin", out var ToUin); this.ToUser = ToUin?.ToObject <long>() ?? 0; em.TryGetValue("MsgType", out var MsgType); this.MsgType = MsgType?.ToString(); em.TryGetValue("MsgSeq", out var MsgSeq); this.MsgSeq = MsgSeq?.ToObject <long>() ?? 0; em.TryGetValue("Content", out var Content); this.Content = Content?.ToString(); } else { throw new Exception(EC.E00); } }