lets hope

This commit is contained in:
Hamcha 2017-08-07 15:42:39 +02:00
parent c97576b635
commit a24ac0b30a

View file

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