lets hope

This commit is contained in:
Hamcha 2017-08-07 15:42:39 +02:00
parent c97576b635
commit a24ac0b30a
1 changed files with 10 additions and 0 deletions

View File

@ -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, "<b>Ecco cosa dicono le stelle:</b>\n"+txt+".", &update.MessageID)