summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'bridge')
-rw-r--r--bridge/config/config.go1
-rw-r--r--bridge/irc/irc.go29
2 files changed, 18 insertions, 12 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 7e6786a8..c5925a1d 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -43,6 +43,7 @@ type Protocol struct {
AuthCode string // steam
BindAddress string // mattermost, slack // DEPRECATED
Buffer int // api
+ Charset string // irc
EditSuffix string // mattermost, slack, discord, telegram, gitter
EditDisable bool // mattermost, slack, discord, telegram, gitter
IconURL string // mattermost, slack
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 36b01b6c..5176389b 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -265,20 +265,25 @@ func (b *Birc) handlePrivMsg(event *irc.Event) {
re := regexp.MustCompile(`[[:cntrl:]](\d+,|)\d+`)
msg = re.ReplaceAllString(msg, "")
- // detect what were sending so that we convert it to utf-8
- detector := chardet.NewTextDetector()
- result, err := detector.DetectBest([]byte(msg))
- if err != nil {
- flog.Infof("detection failed for msg: %#v", msg)
- return
- }
- flog.Debugf("detected %s confidence %#v", result.Charset, result.Confidence)
var r io.Reader
- r, err = charset.NewReader(result.Charset, strings.NewReader(msg))
- // if we're not sure, just pick ISO-8859-1
- if result.Confidence < 80 {
- r, err = charset.NewReader("ISO-8859-1", strings.NewReader(msg))
+ var err error
+ mycharset := b.Config.Charset
+ if mycharset == "" {
+ // detect what were sending so that we convert it to utf-8
+ detector := chardet.NewTextDetector()
+ result, err := detector.DetectBest([]byte(msg))
+ if err != nil {
+ flog.Infof("detection failed for msg: %#v", msg)
+ return
+ }
+ flog.Debugf("detected %s confidence %#v", result.Charset, result.Confidence)
+ r, err = charset.NewReader(result.Charset, strings.NewReader(msg))
+ // if we're not sure, just pick ISO-8859-1
+ if result.Confidence < 80 {
+ mycharset = "ISO-8859-1"
+ }
}
+ r, err = charset.NewReader(mycharset, strings.NewReader(msg))
if err != nil {
flog.Errorf("charset to utf-8 conversion failed: %s", err)
return