mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-22 02:32:02 -08:00
Convert utf-8 back to charset (irc). #247
This commit is contained in:
parent
9e03fcf162
commit
37c350f19f
@ -1,6 +1,7 @@
|
|||||||
package birc
|
package birc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/42wim/go-ircevent"
|
"github.com/42wim/go-ircevent"
|
||||||
@ -132,6 +133,19 @@ func (b *Birc) Send(msg config.Message) (string, error) {
|
|||||||
if strings.HasPrefix(msg.Text, "!") {
|
if strings.HasPrefix(msg.Text, "!") {
|
||||||
b.Command(&msg)
|
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") {
|
for _, text := range strings.Split(msg.Text, "\n") {
|
||||||
if len(text) > b.Config.MessageLength {
|
if len(text) > b.Config.MessageLength {
|
||||||
text = text[:b.Config.MessageLength] + " <message clipped>"
|
text = text[:b.Config.MessageLength] + " <message clipped>"
|
||||||
|
Loading…
Reference in New Issue
Block a user