public static string GetLog(BaseDTO dto) { var sb = InitLogLine(Enum.GetName(typeof(EventType), dto.EventType)); sb.Append(dto.ToJSON()); return(sb.ToString()); }
private void Network_onReceiveEvent(BaseDTO dto) { Output.SendLog(Formatter.GetLog(dto)); Output.SendWebhook(dto); #if DEBUG Utils.Log.Debug(string.Format("[{0}] {1}", dto.EventType, dto.ToJSON())); #endif if (!ShouldSendNotice(dto)) { return; } var output = Formatter.GetEventText(dto); Output.Send(output); }
public static void SendWebhook(BaseDTO dto, ConfigWebhook webhook) { var eventName = Enum.GetName(typeof(EventType), dto.EventType); if (webhook.Type == RequestType.JSON) { var content = new JObject( new JProperty("event", eventName), new JProperty("data", JToken.FromObject(dto))); _ = Request.SendJson(webhook.Endpoint, webhook.Header, content.ToString()); } else { _ = Request.Send(webhook.Endpoint, webhook.Type, webhook.Header, new Dictionary <string, string> { { "event", eventName }, { "data", dto.ToJSON() } }); } }
public static string GetEventText(BaseDTO dto) { switch (dto.EventType) { case EventType.MatchAlert: return(GetInstanceText((MatchAlertDTO)dto)); case EventType.Fate: var fateDto = (FateDTO)dto; if (fateDto.Type == "start") { return(GetFateText(fateDto.Fate)); } else if (fateDto.Type == "progress") { var fateText = GetFateText(fateDto.Fate); if (string.IsNullOrEmpty(fateText)) { return(null); } if (fateDto.Progress != 0) { return(string.Format("{0} 进度 {1}%", fateText, fateDto.Progress)); } else { return(fateText); } } return(null); case EventType.FishBite: return(GetFishText((FishBiteDTO)dto)); case EventType.InitZone: var zoneText = GetZoneText((InitZoneDTO)dto); if (string.IsNullOrEmpty(zoneText)) { return(null); } return(zoneText); case EventType.DynamicEvent: return(GetDynamicEventText((DynamicEventDTO)dto)); default: return(string.Format("{0} {1}", Enum.GetName(typeof(EventType), dto.EventType), dto.ToJSON())); } }