From a24ac0b30a10e6af33d588a088772ec5258a29e3 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Mon, 7 Aug 2017 15:42:39 +0200 Subject: [PATCH] lets hope --- mods/oroscopo.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)