From 9bbdf70e69182c9677152bc69109a5992700192e Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 27 Nov 2022 01:50:46 +0300 Subject: [PATCH 1/3] Fix telegram attachment comment formatting and escaping (#1920) --- bridge/telegram/handlers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index ad41354e..b9cc7e6f 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -451,6 +451,11 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64, parentID Name: fi.Name, Bytes: *fi.Data, } + + if b.GetString("MessageFormat") == HTMLFormat { + fi.Comment = makeHTML(html.EscapeString(fi.Comment)) + } + switch filepath.Ext(fi.Name) { case ".jpg", ".jpe", ".png": pc := tgbotapi.NewInputMediaPhoto(file) From 3ad5deaff12abdba195824a940ab053ad6630752 Mon Sep 17 00:00:00 2001 From: Jair Sanchez <78786202+jx11r@users.noreply.github.com> Date: Sat, 26 Nov 2022 16:53:48 -0600 Subject: [PATCH 2/3] Fix empty messages on IRC (#1897) --- bridge/helper/helper.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index fb65d8d9..0208dff1 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -86,6 +86,12 @@ func GetSubLines(message string, maxLineLength int, clippingMessage string) []st var lines []string for _, line := range strings.Split(strings.TrimSpace(message), "\n") { + if line == "" { + // Prevent sending empty messages, so we'll skip this line + // if it has no content. + continue + } + if maxLineLength == 0 || len([]byte(line)) <= maxLineLength { lines = append(lines, line) continue From 6d5a3dff2279f9cc1e9a846419c6cae2fe563e8d Mon Sep 17 00:00:00 2001 From: Kufat Date: Sat, 26 Nov 2022 18:01:10 -0500 Subject: [PATCH 3/3] Allow substitution of bot's nick in RunCommands (irc) (#1890) * Allow substitution of bot's nick in RunCommands * Tweak description of "{BOTNICK}" Made the description of "{BOTNICK}" consistent with that of other keywords --- bridge/irc/handlers.go | 1 + matterbridge.toml.sample | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go index 987df2c5..74db7685 100644 --- a/bridge/irc/handlers.go +++ b/bridge/irc/handlers.go @@ -243,6 +243,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) { func (b *Birc) handleRunCommands() { for _, cmd := range b.GetStringSlice("RunCommands") { + cmd = strings.ReplaceAll(cmd, "{BOTNICK}", b.Nick) if err := b.i.Cmd.SendRaw(cmd); err != nil { b.Log.Errorf("RunCommands %s failed: %s", cmd, err) } diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 97b27d73..20800689 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -122,10 +122,11 @@ RejoinDelay=0 #Only works in IRC right now. ColorNicks=false -#RunCommands allows you to send RAW irc commands after connection +#RunCommands allows you to send RAW irc commands after connection. +#The string {BOTNICK} (case sensitive) will be replaced with the bot's current nickname. #Array of strings #OPTIONAL (default empty) -RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something"] +RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something", "MODE {BOTNICK} +B"] #PingDelay specifies how long to wait to send a ping to the irc server. #You can use s for second, m for minute