Skip to content

Commit

Permalink
Use discord username from config (#217)
Browse files Browse the repository at this point in the history
* 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 <sandeep@projectdiscovery.io>
  • Loading branch information
3 people authored Feb 26, 2023
1 parent 5fd6cc8 commit b2d78b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |


Expand Down
5 changes: 4 additions & 1 deletion pkg/providers/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package discord

import (
"fmt"
"net/url"

"github.com/containrrr/shoutrrr"
"github.com/oriser/regroup"
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit b2d78b3

Please sign in to comment.