4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-03 09:37:44 +00:00

Add initial transmitter implementation (discord)

This has been tested with one webhook in one channel.

Sends, edits and deletions work fine
This commit is contained in:
Qais Patankar
2020-11-30 05:47:02 +00:00
committed by Wim
parent 611fb279bc
commit 52e2f926f4
5 changed files with 370 additions and 119 deletions

View File

@ -196,7 +196,7 @@ func (b *Bdiscord) replaceAction(text string) (string, bool) {
}
// splitURL splits a webhookURL and returns the ID and token.
func (b *Bdiscord) splitURL(url string) (string, string) {
func (b *Bdiscord) splitURL(url string) (string, string, bool) {
const (
expectedWebhookSplitCount = 7
webhookIdxID = 5
@ -204,9 +204,9 @@ func (b *Bdiscord) splitURL(url string) (string, string) {
)
webhookURLSplit := strings.Split(url, "/")
if len(webhookURLSplit) != expectedWebhookSplitCount {
b.Log.Fatalf("%s is no correct discord WebhookURL", url)
return "", "", false
}
return webhookURLSplit[webhookIdxID], webhookURLSplit[webhookIdxToken]
return webhookURLSplit[webhookIdxID], webhookURLSplit[webhookIdxToken], true
}
func enumerateUsernames(s string) []string {