5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 03:30:26 +00:00

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>
This commit is contained in:
mvoolt 2023-03-10 23:57:35 +02:00 committed by GitHub
parent 544cd5cd9e
commit a3deb48726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -42,7 +42,14 @@ func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) {
if part.Image == nil { if part.Image == nil {
rmsg.Text = part.Text rmsg.Text = part.Text
} else { } 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{}) rmsg.Extra = make(map[string][]interface{})
if err = helper.HandleDownloadSize(b.Log, &rmsg, fname, int64(len(part.Image)), b.General); err != nil { 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") 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 // No need to talk or listen
event.Client.Self.SetSelfDeafened(true) event.Client.Self.SetSelfDeafened(true)
event.Client.Self.SetSelfMuted(true)
// if the Channel variable is set, this is a reconnect -> rejoin channel // if the Channel variable is set, this is a reconnect -> rejoin channel
if b.Channel != nil { if b.Channel != nil {
if err := b.doJoin(event.Client, *b.Channel); err != nil { if err := b.doJoin(event.Client, *b.Channel); err != nil {

View File

@ -250,10 +250,15 @@ func (b *Bmumble) processMessage(msg *config.Message) {
// If there is a maximum message length, split and truncate the lines // If there is a maximum message length, split and truncate the lines
var msgLines []string var msgLines []string
if maxLength := b.serverConfig.MaximumMessageLength; maxLength != nil { if maxLength := b.serverConfig.MaximumMessageLength; maxLength != nil {
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")) msgLines = helper.GetSubLines(msg.Text, *maxLength-len(msg.Username), b.GetString("MessageClipped"))
} else { } else {
msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped")) msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
} }
} else {
msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
}
// Send the individual lines // Send the individual lines
for i := range msgLines { for i := range msgLines {
// Remove unnecessary newline character, since either way we're sending it as individual lines // Remove unnecessary newline character, since either way we're sending it as individual lines