SHOULD WORK NOW
This commit is contained in:
parent
9685fc3449
commit
8c09558922
1 changed files with 9 additions and 9 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue