summaryrefslogtreecommitdiffstats
path: root/bridge/irc/irc.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-08-30 20:59:54 +0200
committerWim <wim@42.be>2017-08-30 20:59:54 +0200
commit37c350f19f2f3f165684e9954ad20485375434ae (patch)
treefebfc42d65e4583ff1d97b89735cf86740c99aa9 /bridge/irc/irc.go
parent9e03fcf1625aa7072ea5177b8a5d318b6f2995cd (diff)
downloadmatterbridge-msglm-37c350f19f2f3f165684e9954ad20485375434ae.tar.gz
matterbridge-msglm-37c350f19f2f3f165684e9954ad20485375434ae.tar.bz2
matterbridge-msglm-37c350f19f2f3f165684e9954ad20485375434ae.zip
Convert utf-8 back to charset (irc). #247
Diffstat (limited to 'bridge/irc/irc.go')
-rw-r--r--bridge/irc/irc.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index aecd85fd..d62fe31a 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -1,6 +1,7 @@
package birc
import (
+ "bytes"
"crypto/tls"
"fmt"
"github.com/42wim/go-ircevent"
@@ -132,6 +133,19 @@ func (b *Birc) Send(msg config.Message) (string, error) {
if strings.HasPrefix(msg.Text, "!") {
b.Command(&msg)
}
+
+ if b.Config.Charset != "" {
+ buf := new(bytes.Buffer)
+ w, err := charset.NewWriter(b.Config.Charset, buf)
+ if err != nil {
+ flog.Errorf("charset from utf-8 conversion failed: %s", err)
+ return "", err
+ }
+ fmt.Fprintf(w, msg.Text)
+ w.Close()
+ msg.Text = buf.String()
+ }
+
for _, text := range strings.Split(msg.Text, "\n") {
if len(text) > b.Config.MessageLength {
text = text[:b.Config.MessageLength] + " <message clipped>"