diff --git a/mods/oroscopo.go b/mods/oroscopo.go index dd94817..c2c83f7 100644 --- a/mods/oroscopo.go +++ b/mods/oroscopo.go @@ -4,6 +4,7 @@ import ( "log" "os" "strings" + "unicode" "io/ioutil" "path/filepath" @@ -48,12 +49,21 @@ func oroscopo(broker *tg.Broker, update tg.APIMessage) { tries++ continue } + // Find end idx := strings.LastIndexByte(txt, '.') if idx < 10 { tries++ continue } txt = txt[:idx] + + // Find beginning + idx = strings.IndexFunc(txt, unicode.IsUpper) + if idx < 0 { + tries++ + continue + } + txt = txt[idx:] break } broker.SendTextMessage(update.Chat, "Ecco cosa dicono le stelle:\n"+txt+".", &update.MessageID)