summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authormvoolt <77506726+mvoolt@users.noreply.github.com>2023-03-10 23:57:35 +0200
committerGitHub <noreply@github.com>2023-03-10 22:57:35 +0100
commita3deb4872656389425c8d3b9abb7c7d428bb8fe7 (patch)
tree25e4bcab31aeb0e20214aaf2f876f14d45201ac9 /bridge
parent544cd5cd9ee8fc48b4056a10316f79d6a96c63bb (diff)
downloadmatterbridge-msglm-a3deb4872656389425c8d3b9abb7c7d428bb8fe7.tar.gz
matterbridge-msglm-a3deb4872656389425c8d3b9abb7c7d428bb8fe7.tar.bz2
matterbridge-msglm-a3deb4872656389425c8d3b9abb7c7d428bb8fe7.zip
Add support for Mumble servers with no message length limit (#2008)
* Rename .{jfif,jpe} to .jpg (mumble) * Fix messages not sending in properly if no limit is set (mumble) Co-authored-by: yellows111 <ice_ice@email.com> * Formatting fix (mumble) --------- Co-authored-by: yellows111 <ice_ice@email.com>
Diffstat (limited to 'bridge')
-rw-r--r--bridge/mumble/handlers.go10
-rw-r--r--bridge/mumble/mumble.go7
2 files changed, 14 insertions, 3 deletions
diff --git a/bridge/mumble/handlers.go b/bridge/mumble/handlers.go
index 8120159a..830aa5c0 100644
--- a/bridge/mumble/handlers.go
+++ b/bridge/mumble/handlers.go
@@ -42,7 +42,14 @@ func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) {
if part.Image == nil {
rmsg.Text = part.Text
} else {
- fname := b.Account + "_" + strconv.FormatInt(now.UnixNano(), 10) + "_" + strconv.Itoa(i) + part.FileExtension
+ fileExt := part.FileExtension
+ if fileExt == ".jfif" {
+ fileExt = ".jpg"
+ }
+ if fileExt == ".jpe" {
+ fileExt = ".jpg"
+ }
+ fname := b.Account + "_" + strconv.FormatInt(now.UnixNano(), 10) + "_" + strconv.Itoa(i) + fileExt
rmsg.Extra = make(map[string][]interface{})
if err = helper.HandleDownloadSize(b.Log, &rmsg, fname, int64(len(part.Image)), b.General); err != nil {
b.Log.WithError(err).Warn("not including image in message")
@@ -62,7 +69,6 @@ func (b *Bmumble) handleConnect(event *gumble.ConnectEvent) {
}
// No need to talk or listen
event.Client.Self.SetSelfDeafened(true)
- event.Client.Self.SetSelfMuted(true)
// if the Channel variable is set, this is a reconnect -> rejoin channel
if b.Channel != nil {
if err := b.doJoin(event.Client, *b.Channel); err != nil {
diff --git a/bridge/mumble/mumble.go b/bridge/mumble/mumble.go
index 945cf559..859ca4ab 100644
--- a/bridge/mumble/mumble.go
+++ b/bridge/mumble/mumble.go
@@ -250,7 +250,12 @@ func (b *Bmumble) processMessage(msg *config.Message) {
// If there is a maximum message length, split and truncate the lines
var msgLines []string
if maxLength := b.serverConfig.MaximumMessageLength; maxLength != nil {
- msgLines = helper.GetSubLines(msg.Text, *maxLength-len(msg.Username), b.GetString("MessageClipped"))
+ if *maxLength != 0 { // Some servers will have unlimited message lengths.
+ // Not doing this makes underflows happen.
+ msgLines = helper.GetSubLines(msg.Text, *maxLength-len(msg.Username), b.GetString("MessageClipped"))
+ } else {
+ msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
+ }
} else {
msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
}