diff options
author | ValdikSS <iam@valdikss.org.ru> | 2019-01-05 17:42:36 +0300 |
---|---|---|
committer | Wim <wim@42.be> | 2019-01-05 15:42:36 +0100 |
commit | 7326b9e10dc117654c2646d4765ad8b6298e003f (patch) | |
tree | 502d039af897510aba856dcd9eb75aa4e4d3a574 /bridge/sshchat/sshchat.go | |
parent | 8522d8f29cf1625a0d31dab15428600133fe0dba (diff) | |
download | matterbridge-msglm-7326b9e10dc117654c2646d4765ad8b6298e003f.tar.gz matterbridge-msglm-7326b9e10dc117654c2646d4765ad8b6298e003f.tar.bz2 matterbridge-msglm-7326b9e10dc117654c2646d4765ad8b6298e003f.zip |
Add various sshchat fixes (#675)
* SSH-Chat: set quiet mode to filter joins/quits
* SSH-Chat: Trim newlines in the end of relayed messages
* SSH-Chat: fix media links
* SSH-Chat: do not relay "Rate limiting is in effect" message
Diffstat (limited to 'bridge/sshchat/sshchat.go')
-rw-r--r-- | bridge/sshchat/sshchat.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go index ca427a81..5a8029cf 100644 --- a/bridge/sshchat/sshchat.go +++ b/bridge/sshchat/sshchat.go @@ -33,7 +33,7 @@ func (b *Bsshchat) Connect() error { b.r = bufio.NewScanner(r) b.r.Scan() b.w = w - if _, err := b.w.Write([]byte("/theme mono\r\n")); err != nil { + if _, err := b.w.Write([]byte("/theme mono\r\n/quiet\r\n")); err != nil { return err } close(connSignal) // Connection is established so we can signal the success. @@ -128,6 +128,9 @@ func (b *Bsshchat) handleSSHChat() error { if !strings.Contains(b.r.Text(), "\033[K") { continue } + if strings.Contains(b.r.Text(), "Rate limiting is in effect") { + continue + } res := strings.Split(stripPrompt(b.r.Text()), ":") if res[0] == "-> Set theme" { wait = false @@ -136,7 +139,7 @@ func (b *Bsshchat) handleSSHChat() error { } if !wait { b.Log.Debugf("<= Message %#v", res) - rmsg := config.Message{Username: res[0], Text: strings.Join(res[1:], ":"), Channel: "sshchat", Account: b.Account, UserID: "nick"} + rmsg := config.Message{Username: res[0], Text: strings.TrimSpace(strings.Join(res[1:], ":")), Channel: "sshchat", Account: b.Account, UserID: "nick"} b.Remote <- rmsg } } @@ -155,7 +158,7 @@ func (b *Bsshchat) handleUploadFile(msg *config.Message) (string, error) { msg.Text = fi.Comment + ": " + fi.URL } } - if _, err := b.w.Write([]byte(msg.Username + msg.Text)); err != nil { + if _, err := b.w.Write([]byte(msg.Username + msg.Text + "\r\n")); err != nil { b.Log.Errorf("Could not send file message: %#v", err) } } |