lets hope
This commit is contained in:
parent
c97576b635
commit
a24ac0b30a
1 changed files with 10 additions and 0 deletions
|
@ -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)
|
||||||
|
|
Reference in a new issue