babbler: create tables no matter what

This commit is contained in:
Chris Sexton 2017-10-25 18:45:45 -04:00
parent df29c89d84
commit 6af9114a37
1 changed files with 33 additions and 35 deletions

View File

@ -56,7 +56,6 @@ type BabblerArc struct {
func New(bot bot.Bot) *BabblerPlugin {
log.SetFlags(log.LstdFlags | log.Lshortfile)
if bot.DBVersion() == 1 {
if _, err := bot.DB().Exec(`create table if not exists babblers (
id integer primary key,
babbler string
@ -89,7 +88,6 @@ func New(bot bot.Bot) *BabblerPlugin {
);`); err != nil {
log.Fatal(err)
}
}
plugin := &BabblerPlugin{
Bot: bot,
@ -792,8 +790,8 @@ func (p *BabblerPlugin) babbleSeedSuffix(babblerName string, seed []string) (str
}
}
for i := 0; i < len(words) / 2; i++ {
index := len(words)-(i+1)
for i := 0; i < len(words)/2; i++ {
index := len(words) - (i + 1)
words[i], words[index] = words[index], words[i]
}
@ -864,8 +862,8 @@ func (p *BabblerPlugin) babbleSeedBookends(babblerName string, start, end []stri
previous *searchNode
}
open := []*searchNode{ &searchNode{startWordNode.NodeId, nil} }
closed := map[int64]*searchNode{ startWordNode.NodeId : open[0] }
open := []*searchNode{&searchNode{startWordNode.NodeId, nil}}
closed := map[int64]*searchNode{startWordNode.NodeId: open[0]}
goalNodeId := int64(-1)
for i := 0; i < len(open) && i < 1000; i++ {
@ -927,8 +925,8 @@ func (p *BabblerPlugin) babbleSeedBookends(babblerName string, start, end []stri
}
}
for i := 0; i < len(words) / 2; i++ {
index := len(words)-(i+1)
for i := 0; i < len(words)/2; i++ {
index := len(words) - (i + 1)
words[i], words[index] = words[index], words[i]
}