From b2d78b3e7784eae57cc2cf3023b20109443a0af3 Mon Sep 17 00:00:00 2001 From: Jorian Date: Sun, 26 Feb 2023 11:36:08 +0100 Subject: [PATCH] Use discord username from config (#217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix a spelling mistake in README.md change example `notify -version` to `notify -verbose`. It's a small typo. * Use discord username from config --------- Co-authored-by: 程越 <44216455+cyicz123@users.noreply.github.com> Co-authored-by: Sandeep Singh --- README.md | 2 +- pkg/providers/discord/discord.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e1bfc4d..2d8736c 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ This will display help for the tool. Here are all the switches it supports. | `-proxy` | http proxy to use with notify | `notify -proxy http://127.0.0.1:8080` | | `-rate-limit` | maximum number of HTTP requests to send per second | `notify -rl 1` | | `-silent` | enable silent mode | `notify -silent` | -| `-verbose` | enable verbose mode | `notify -version` | +| `-verbose` | enable verbose mode | `notify -verbose` | | `-version` | display version | `notify -version` | diff --git a/pkg/providers/discord/discord.go b/pkg/providers/discord/discord.go index 4decc10..a8e66c2 100644 --- a/pkg/providers/discord/discord.go +++ b/pkg/providers/discord/discord.go @@ -2,6 +2,7 @@ package discord import ( "fmt" + "net/url" "github.com/containrrr/shoutrrr" "github.com/oriser/regroup" @@ -55,7 +56,9 @@ func (p *Provider) Send(message, CliFormat string) error { } webhookID, webhookToken := matchedGroups["webhook_identifier"], matchedGroups["webhook_token"] - url := fmt.Sprintf("discord://%s@%s?splitlines=no", webhookToken, webhookID) + url := fmt.Sprintf("discord://%s@%s?splitlines=no&username=%s", webhookToken, webhookID, + url.QueryEscape(pr.DiscordWebHookUsername)) + sendErr := shoutrrr.Send(url, msg) if sendErr != nil { sendErr = errors.Wrap(sendErr, fmt.Sprintf("failed to send discord notification for id: %s ", pr.ID))