SHOULD WORK NOW

This commit is contained in:
Hamcha 2017-08-07 15:33:58 +02:00
parent 9685fc3449
commit 8c09558922

View file

@ -13,7 +13,6 @@ import (
)
var orogen *mctext.MChain
var orocorpus *strings.Reader
func initoroscopo() {
counter := 0
@ -34,25 +33,26 @@ func initoroscopo() {
return nil
})
orocorpus = strings.NewReader(corpus)
orogen := mctext.New()
orogen.Parse(orocorpus)
orogen = mctext.New()
orogen.Parse(strings.NewReader(corpus))
log.Printf("[oroscopo] Loaded corpus from %d files\n", counter)
}
func oroscopo(broker *tg.Broker, update tg.APIMessage) {
if isCommand(update, "oroscopo") {
for {
txt := orogen.Generate("", 100)
txt := ""
tries := 0
for tries < 10 {
txt = orogen.Generate("", 100)
idx := strings.LastIndexByte(txt, '.')
if idx < 10 {
tries++
continue
}
txt = txt[:idx]
broker.SendTextMessage(update.Chat, "<b>Ecco cosa dicono le stelle:</b>\n"+txt, &update.MessageID)
return
break
}
broker.SendTextMessage(update.Chat, "<b>Ecco cosa dicono le stelle:</b>\n"+txt+".", &update.MessageID)
}
}