1
0
mirror of https://github.com/ManyakRus/telegram_loki.git synced 2024-12-04 21:05:12 +02:00

сделал EscapeString()

This commit is contained in:
Nikitin Aleksandr 2024-11-21 11:19:29 +03:00
parent 8d260a0c16
commit 153377a3c0
8 changed files with 18 additions and 10 deletions

View File

@ -1 +1 @@
2024-11-21 07:34:31.530
2024-11-21 08:19:21.561

View File

@ -1 +1 @@
00188
00189

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/ManyakRus/telegram_loki
go 1.22.1
require (
github.com/ManyakRus/starter v1.0.86
github.com/ManyakRus/starter v1.0.87
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
github.com/golang-module/carbon/v2 v2.4.1
github.com/jackc/pgx/v5 v5.7.1

4
go.sum
View File

@ -2,8 +2,8 @@ github.com/DataDog/zstd v1.5.6 h1:LbEglqepa/ipmmQJUDnSsfvA8e8IStVcGaFWDuxvGOY=
github.com/DataDog/zstd v1.5.6/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/ManyakRus/logrus v0.0.0-20231019115155-9e6fede0d792 h1:bxwxD0H3kSUAH3uNk/b74gkImcUiP7dyibmMoVwk338=
github.com/ManyakRus/logrus v0.0.0-20231019115155-9e6fede0d792/go.mod h1:OUyxCVbPW/2lC1e6cM7Am941SJiC88BhNnb24x2R3a8=
github.com/ManyakRus/starter v1.0.86 h1:saxWu1qper3moVXzN1rf3cc2zCIHk4Y6X4Kxvgo8V5Y=
github.com/ManyakRus/starter v1.0.86/go.mod h1:ildteZO1poRllhuCistAbG14f/BGjCkCG4dnf5DwfUE=
github.com/ManyakRus/starter v1.0.87 h1:AReqS2A6QaoB8NhSCR/ka73jQ+6qeGBvRZLck98u4Mw=
github.com/ManyakRus/starter v1.0.87/go.mod h1:ildteZO1poRllhuCistAbG14f/BGjCkCG4dnf5DwfUE=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=

View File

@ -11,6 +11,7 @@ import (
"github.com/ManyakRus/telegram_loki/internal/load_json"
"github.com/ManyakRus/telegram_loki/internal/types"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"html"
"strings"
)
@ -39,8 +40,12 @@ func SendMessage(Message1 types.Message) error {
TextDate = ""
}
DeveloperName := Message1.DeveloperName
Text := Message1.Text
//экранируем запрещённые символы
Text := Message1.Text
Text = html.EscapeString(Text)
//
TextServiceName := Message1.ServiceName
if Message1.LokiURL != "" {
TextServiceName = `<a href="` + Message1.LokiURL + `">` + Message1.ServiceName + "</a>"
@ -70,7 +75,11 @@ func SendMessage(Message1 types.Message) error {
return err
}
//экранируем запрещённые символы
Text = Message1.Text
Text = html.EscapeString(Text)
//
if TextServiceName != "" {
Text = TextServiceName + "\n" + Text
}

View File

@ -1 +1 @@
335cc3a 2024-11-21 10:22:35 +0300
8d260a0 2024-11-21 10:35:03 +0300

View File

@ -8,7 +8,6 @@ import (
"github.com/ManyakRus/starter/micro"
"github.com/ManyakRus/starter/stopapp"
botapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"html"
"os"
"sync"
)
@ -143,7 +142,7 @@ func SendMessage(UserName string, Text string) (int, error) {
var err error
//экранируем запрещённые символы
Text = html.EscapeString(Text)
//Text = html.EscapeString(Text)
//
msg := botapi.NewMessageToChannel(UserName, Text)

2
vendor/modules.txt vendored
View File

@ -4,7 +4,7 @@ github.com/DataDog/zstd
# github.com/ManyakRus/logrus v0.0.0-20231019115155-9e6fede0d792
## explicit; go 1.13
github.com/ManyakRus/logrus
# github.com/ManyakRus/starter v1.0.86
# github.com/ManyakRus/starter v1.0.87
## explicit; go 1.22.1
github.com/ManyakRus/starter/config_main
github.com/ManyakRus/starter/contextmain