mirror of https://github.com/velour/catbase.git
Spit out a start up message to the chan
This commit is contained in:
parent
0627f8a015
commit
43a8bec86b
|
@ -23,6 +23,8 @@
|
||||||
"TwitterUserKey": "<User Key>",
|
"TwitterUserKey": "<User Key>",
|
||||||
"TwitterUserSecret": "<User Secret>",
|
"TwitterUserSecret": "<User Secret>",
|
||||||
|
|
||||||
|
"StartupFact": "speed test",
|
||||||
|
|
||||||
"WelcomeMsgs": [
|
"WelcomeMsgs": [
|
||||||
"Real men use screen, %s.",
|
"Real men use screen, %s.",
|
||||||
"Joins upset the hivemind's OCD, %s.",
|
"Joins upset the hivemind's OCD, %s.",
|
||||||
|
|
|
@ -28,6 +28,7 @@ type Config struct {
|
||||||
TwitterConsumerSecret string
|
TwitterConsumerSecret string
|
||||||
TwitterUserKey string
|
TwitterUserKey string
|
||||||
TwitterUserSecret string
|
TwitterUserSecret string
|
||||||
|
StartupFact string
|
||||||
BadMsgs []string
|
BadMsgs []string
|
||||||
Bad struct {
|
Bad struct {
|
||||||
Msgs []string
|
Msgs []string
|
||||||
|
|
|
@ -41,9 +41,9 @@ type FactoidPlugin struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFactoidPlugin creates a new FactoidPlugin with the Plugin interface
|
// NewFactoidPlugin creates a new FactoidPlugin with the Plugin interface
|
||||||
func NewFactoidPlugin(bot *bot.Bot) *FactoidPlugin {
|
func NewFactoidPlugin(botInst *bot.Bot) *FactoidPlugin {
|
||||||
p := &FactoidPlugin{
|
p := &FactoidPlugin{
|
||||||
Bot: bot,
|
Bot: botInst,
|
||||||
Coll: nil,
|
Coll: nil,
|
||||||
NotFound: []string{
|
NotFound: []string{
|
||||||
"I don't know.",
|
"I don't know.",
|
||||||
|
@ -55,9 +55,23 @@ func NewFactoidPlugin(bot *bot.Bot) *FactoidPlugin {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
p.LoadData()
|
p.LoadData()
|
||||||
for _, channel := range bot.Config.Channels {
|
for _, channel := range botInst.Config.Channels {
|
||||||
go p.factTimer(channel)
|
go p.factTimer(channel)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// Some random time to start up
|
||||||
|
time.Sleep(time.Duration(10) * time.Second)
|
||||||
|
if ok, fact := p.findTrigger(p.Bot.Config.StartupFact); ok {
|
||||||
|
p.sayFact(bot.Message{
|
||||||
|
Channel: channel,
|
||||||
|
Body: "speed test",
|
||||||
|
Command: true,
|
||||||
|
Action: false,
|
||||||
|
}, *fact)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +127,7 @@ func (p *FactoidPlugin) findTrigger(message string) (bool, *Factoid) {
|
||||||
iter := p.Coll.Find(bson.M{"trigger": strings.ToLower(message)}).Iter()
|
iter := p.Coll.Find(bson.M{"trigger": strings.ToLower(message)}).Iter()
|
||||||
err := iter.All(&results)
|
err := iter.All(&results)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
nfacts := len(results)
|
nfacts := len(results)
|
||||||
|
|
Loading…
Reference in New Issue