add phonetic explanation

This commit is contained in:
lyx0 2023-05-07 00:30:24 +02:00
parent 665e6b95ea
commit 56fdcfc78e
2 changed files with 24 additions and 6 deletions

View file

@ -62,14 +62,20 @@ func (app *Application) ParseCommand(evt *event.Event) {
} }
case "phonetic": case "phonetic":
msg := evt.Content.AsMessage().Body[9:len(evt.Content.AsMessage().Body)] if msgLen == 1 {
if resp, err := commands.Phonetic(msg); err != nil { resp := commands.PhoneticExplanation()
app.Log.Error().Err(err).Msg("failed to handle phonetic command")
app.SendText(evt, "Something went wrong.")
return
} else {
app.SendText(evt, resp) app.SendText(evt, resp)
return return
} else {
msg := evt.Content.AsMessage().Body[9:len(evt.Content.AsMessage().Body)]
if resp, err := commands.Phonetic(msg); err != nil {
app.Log.Error().Err(err).Msg("failed to handle phonetic command")
app.SendText(evt, "Something went wrong.")
return
} else {
app.SendText(evt, resp)
return
}
} }
case "ping": case "ping":

View file

@ -73,6 +73,18 @@ var cm = map[string]string{
"M": "М", "M": "М",
} }
func PhoneticExplanation() string {
// This might look like complete ass depending on the
// matrix clients font. Looks fine on my Element client.
help := `
| Ё | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | Ъ |
| Я | Ш | Е | Р | Т | Ы | У | И | О | П | Ю | Щ | Э |
| А | С | Д | Ф | Г | Ч | Й | К | Л | Ь | Ж |
| З | Х | Ц | В | Б | Н | М | ; | : |
`
return help
}
func Phonetic(message string) (string, error) { func Phonetic(message string) (string, error) {
var ts string var ts string