Spit out a start up message to the chan

This commit is contained in:
Chris Sexton 2013-08-27 21:52:27 -04:00
parent 0627f8a015
commit 43a8bec86b
3 changed files with 21 additions and 4 deletions

View File

@ -23,6 +23,8 @@
"TwitterUserKey": "<User Key>",
"TwitterUserSecret": "<User Secret>",
"StartupFact": "speed test",
"WelcomeMsgs": [
"Real men use screen, %s.",
"Joins upset the hivemind's OCD, %s.",

View File

@ -28,6 +28,7 @@ type Config struct {
TwitterConsumerSecret string
TwitterUserKey string
TwitterUserSecret string
StartupFact string
BadMsgs []string
Bad struct {
Msgs []string

View File

@ -41,9 +41,9 @@ type FactoidPlugin struct {
}
// NewFactoidPlugin creates a new FactoidPlugin with the Plugin interface
func NewFactoidPlugin(bot *bot.Bot) *FactoidPlugin {
func NewFactoidPlugin(botInst *bot.Bot) *FactoidPlugin {
p := &FactoidPlugin{
Bot: bot,
Bot: botInst,
Coll: nil,
NotFound: []string{
"I don't know.",
@ -55,9 +55,23 @@ func NewFactoidPlugin(bot *bot.Bot) *FactoidPlugin {
},
}
p.LoadData()
for _, channel := range bot.Config.Channels {
for _, channel := range botInst.Config.Channels {
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
}