private void SendMessage(LogEvent logEvent) { var webhookUrl = $"https://discord.com/api/webhooks/{_webhookId}/{_webhookToken}"; var webHook = new Webhook(webhookUrl); try { var obj = SerilogWebhookObjectFactory.Create(logEvent, _formatProvider); webHook.Send(obj); } catch (Exception ex) { webHook.Send(new WebhookObject() { content = $"ooo snap, {ex.Message}" }); } }
IEnumerator SendEmbed(Embed a_embed, string a_discordURL) { Webhook webhook = new Webhook(a_discordURL); List <Embed> embeds = new List <Embed>(); embeds.Add(a_embed); yield return(webhook.Send(string.Empty, "Devil's Delights", "https://cdn.discordapp.com/attachments/706667975171768330/706714712175411250/icon.png", false, embeds)); }
private void HandleHooks(HttpActionExecutedContext actionExecutedContext) { string webhookName = actionExecutedContext.ActionContext.ControllerContext.ControllerDescriptor.ControllerName + "." + actionExecutedContext.ActionContext.ActionDescriptor.ActionName; Webhook webhook = new Webhook(); webhook.Send(webhookName, null, null, null, null, true, null, GetResponseObject, actionExecutedContext); //actionExecutedContext.Response.Content. }
public IHttpActionResult Get(string webhookName) { try { Webhook webhook = new Webhook(); return(Ok(webhook.Send(webhookName))); } catch (WebhookNotFoundException exception) { Maps.Instance.DuradosMap.Logger.Log("webhook", webhookName, this.Request.Method.Method, exception, 1, null, DateTime.Now); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, exception.Message))); } catch (Exception exception) { Maps.Instance.DuradosMap.Logger.Log("webhook", webhookName, this.Request.Method.Method, exception, 1, null, DateTime.Now); throw new BackAndApiUnexpectedResponseException(exception, this); } }
static public async Task SendDiscordPost(ulong id, string token) { if (!discordSetup) { return; } //If the params were validated but there's no content, don't send anything... if (discordContent.Length < 1 || discordContent == String.Empty) { Console.WriteLine("[DiscordNotify]: No content to send was provided, won't send any notifications to discord."); return; } Webhook hook = new Webhook(id, token) { Content = discordContent }; await hook.Send(discordContent); }
public async Task <HttpResponseMessage> PostMessage(string webhookUrl, ProductDetails productDetails, CancellationToken token) { try { string currency = productDetails.Currency.HtmlDeEntitize(); string name = productDetails.Name?.EscapeNewLines().HtmlDeEntitize(); string sizes = string.Join("\n", productDetails.SizesList.Select(sizInfo => $"{sizInfo.Key}[{sizInfo.Value}]".HtmlDeEntitize())); string textMessage = $"*Price*:\n{productDetails.Price + currency}\n" + $"*Store link*:\n{productDetails.Url}\n" + $"*Available sizes are*:\n{sizes}\n"; Embed embed = new Embed() { Title = name, Type = "rich", Description = textMessage, Url = productDetails.Url, Color = 7753637, Thumbnail = new EmbedThumbnail() { Url = productDetails.ImageUrl }, TimeStamp = new DateTimeOffset(DateTime.UtcNow) }; Webhook webhook = new Webhook(webhookUrl, token) { Embeds = new List <Embed> { embed } }; return(await webhook.Send()); } catch (Exception e) { Logger.Instance.WriteErrorLog($"Error occured while posting to slack. \n msg={e.GetMessage()}"); throw; } }
public override void AddLine(NetworkId?id, string message, bool system) { base.AddLine(id, message, system); if (id == null) { return; } if (_myConfig == null) { _myConfig = new Config(); } //Send Chat to Discord if (!_myConfig.getBool("chat_webhook_use")) { return; } Webhook dw = new Webhook(_myConfig.getString("chat_webhook_url")); dw.Send($"{_myConfig.getString("chat_webhook_prefix")}{message}", _players[id.Value]._name); }
static async Task ScanWorkshop() { uint pageNumber = 0; while (true) { pageNumber++; Console.Write("Page Number = " + pageNumber.ToString() + "\n"); WorkshopAddon[] Addons = await WorkshopHTTPAPI.GetWorkshopAddonsAsync(steamApiKey, EPublishedFileQueryType.RankedByPublicationDate, pageNumber, 100); Console.Write("# Addons: {0}\n", Addons.Length.ToString()); if (Addons.Length < 1) { Console.Write("Reached end of workshop."); if (Console.ReadLine() == "ok") { Environment.Exit(1); } } foreach (WorkshopAddon Addon in Addons) { if (DataLog.hasBeenLogged(Addon.ID.ToString()) || DataLog.hasBeenWhitelisted(Addon.ID.ToString())) { continue; } Console.Write("Downloading Addon: {0}\n", Addon.URL); GMADAddon parsedAddon; try { using (var wc = new WebClient()) { Byte[] data = await wc.DownloadDataTaskAsync(Addon.URL); parsedAddon = GMADParser.Parse(data); data = new Byte[0]; } Backdoor backdoorFinder = new Backdoor(parsedAddon); List <List <Backdoor.FlagStruct> > flagList = backdoorFinder.scanFile(); foreach (var flagFile in flagList) { foreach (Backdoor.FlagStruct fileStruct in flagFile) { int lineNumber = fileStruct.lineNumber; String FlagStr = fileStruct.FlagStr; GMADAddon.File AddonFile = fileStruct.AddonFile; GMADAddon._Author Author = parsedAddon.Author; String FlagDescription = fileStruct.FlagDescription; Regex CheckRegex = fileStruct.CheckRegex; int CheckType = fileStruct.CheckType; int Priority = fileStruct.Priority; string AddonUrl = "https://steamcommunity.com/sharedfiles/filedetails/?id=" + Addon.ID.ToString(); Webhook discordWebhook = new Webhook(webhookURL); Embed discordEmbed = new Embed(); List <Embed> embedList = new List <Embed>(); Dictionary <string, string> fieldDict = new Dictionary <string, string>() { { "line number", lineNumber.ToString() }, { "Addon name", parsedAddon.Name }, { "Current File", AddonFile.Path }, { "Priority", Priority.ToString() }, { "Flag", FlagDescription }, { "Code", FlagStr.Length < 1024 ? FlagStr : "Code too long" }, { "Author Name", Author.Name }, { "Author SteamID", Author.SteamID64.ToString() }, { "Addon URL", AddonUrl } }; discordEmbed.Title = "FLAG FOUND"; discordEmbed.Fields = Backdoor.makeEmbedList(fieldDict); discordEmbed.Color = Extensions.ToRgb(Color.FromName("purple")); embedList.Add(discordEmbed); await discordWebhook.Send(null, null, null, false, embedList); } } if (flagList.Count < 1) { Console.Write("No flags found.\n"); } BackdoorData toLog = DataLog.toData(Addon.ID.ToString(), Addon.URL); DataLog.addData(toLog); flagList = null; backdoorFinder = null; GC.Collect(); } catch (Exception ex) { Console.Write("Something went wrong...\n"); Console.Write(ex.Message + "\n"); } } } }
private void PlayerLeft(String p) { Webhook dw = new Webhook(_myConfig.getString("left_webhook_url")); dw.Send(_myConfig.getString("left_webhook_msg").Replace("%p", p)); }
public virtual IHttpActionResult Delete(string id) { try { if (string.IsNullOrEmpty(id)) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.IdIsMissing))); } View view = GetView(null); if (view == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ViewNameNotFound, AppViewName)))); } if (!view.IsDeletable()) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.ViewIsUnauthorized))); } int?appId = Maps.Instance.AppExists(id, Convert.ToInt32(Maps.Instance.DuradosMap.Database.GetUserID())); if (!appId.HasValue) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ItemWithIdNotFound, id, AppViewName)))); } string guid = GetMasterGuid(); string qstring = "id=" + guid; try { Durados.Web.Mvc.Infrastructure.ProductMaintenance productMaintenece = new Durados.Web.Mvc.Infrastructure.ProductMaintenance(); productMaintenece.RemoveApp(id); } catch (Exception exception) { Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", id, exception, 1, "The app " + id + " has productMaintenece errors"); } //url = GetDeleteAppUrl(id); //string response = Durados.Web.Mvc.Infrastructure.Http.GetWebRequest(url,string.Empty,string.Empty, 100000); //Dictionary<string, object> ret = Durados.Web.Mvc.UI.Json.JsonSerializer.Deserialize(response); try { CronHelper.DeleteAllCrons(Maps.Instance.AppExists(id).Value.ToString()); } catch (Exception exception) { Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", id, exception, 1, "Failed to delete all app crons"); } try { Webhook webhook = new Webhook(); try { webhook.Send(WebhookType.AppDeleted, GetBody(id, Maps.Instance.DuradosMap.Database.GetCurrentUsername())); Maps.Instance.DuradosMap.Logger.Log("webhook", "AppDeleted", this.Request.Method.Method, null, 3, null, DateTime.Now); } catch (Exception exception) { webhook.HandleException(WebhookType.AppDeleted, exception); } } catch { } string sql = "delete durados_App where name = '" + id + "'"; (new SqlAccess()).ExecuteNonQuery(Maps.Instance.DuradosMap.connectionString, sql); Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", "", null, 1, "The app " + id + " was deleted"); //Maps.Instance.Restart(id); RestHelper.Refresh(id); FarmCachingSingeltone.Instance.ClearMachinesCache(id); //RefreshOldAdmin(id); return(Ok()); } catch (Exception exception) { throw new BackAndApiUnexpectedResponseException(exception, this); } }