Skip to content

Commit

Permalink
messenger: Add hostname before every discord msg
Browse files Browse the repository at this point in the history
  • Loading branch information
victorges committed Mar 21, 2022
1 parent 9f4da91 commit 0bb5f48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
4 changes: 1 addition & 3 deletions internal/app/recordtester/continuous_record_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"net/url"
"os"
"strconv"
"time"

Expand Down Expand Up @@ -66,8 +65,7 @@ func NewContinuousRecordTester(gctx context.Context, opts ContinuousRecordTester
}

func (crt *continuousRecordTester) Start(fileName string, testDuration, pauseDuration, pauseBetweenTests time.Duration) error {
hostname, _ := os.Hostname()
messenger.SendMessage(fmt.Sprintf("Starting continuous test of %s on hostname=%s", crt.host, hostname))
messenger.SendMessage(fmt.Sprintf("Starting continuous test of %s", crt.host))
try := 0
notRtmpTry := 0
maxTestDuration := 2*testDuration + pauseDuration + 15*time.Minute
Expand Down
22 changes: 5 additions & 17 deletions messenger/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ package messenger
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"time"

Expand Down Expand Up @@ -300,6 +302,8 @@ func sendLoop() {
}
}

var hostname, _ = os.Hostname()

func sendMessage(msg string) {
if len(msg) > maxMessageLen {
for {
Expand All @@ -316,30 +320,14 @@ func sendMessage(msg string) {
}
return
}
msg = fmt.Sprintf("%s: %s", hostname, msg)
sendRawMessage(encodeMessage(msg))
}

func sendRawMessage(msg []byte) {
if webhookURL == "" || msgCh == nil {
return
}
/*
if len(msg) > maxMessageLen {
for {
l := maxMessageLen - 10
if l > len(msg) {
l = len(msg)
}
msg1 := msg[:l]
msg = msg[l:]
sendMessage(msg1)
if len(msg) == 0 {
break
}
}
return
}
*/
msgCh <- msg
}

Expand Down

0 comments on commit 0bb5f48

Please sign in to comment.