Add transliteration

This commit is contained in:
2021-10-04 01:05:01 -07:00
parent 419b2f5a79
commit 1db2ca3395
5 changed files with 492 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"go.arsenm.dev/infinitime"
"go.arsenm.dev/itd/translit"
)
func initNotifRelay(dev *infinitime.Device) error {
@@ -71,6 +72,13 @@ func initNotifRelay(dev *infinitime.Device) error {
continue
}
maps := viper.GetStringSlice("notifs.translit.maps.use")
translit.Maps["custom"] = viper.GetStringSlice("notifs.translit.maps.custom")
replacer := translit.NewReplacer(maps...)
sender = replacer.Replace(sender)
summary = replacer.Replace(summary)
body = replacer.Replace(body)
var msg string
// If summary does not exist, set message to body.
// If it does, set message to summary, two newlines, and then body