-
-
Save whyrusleeping/736fd616e5852744bef7 to your computer and use it in GitHub Desktop.
sprintbot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
hb "github.com/whyrusleeping/hellabot" | |
"time" | |
) | |
func getNextSprintTime() time.Time { | |
n := time.Now() | |
loc, err := time.LoadLocation("America/Los_Angeles") | |
if err != nil { | |
panic(err) | |
} | |
next := time.Date(n.Year(), n.Month(), n.Day(), 12, 0, 0, 0, loc) | |
if n.Hour() >= 12 { | |
next = next.Add(time.Hour * 24) | |
} | |
return next | |
} | |
func main() { | |
con, err := hb.NewIrcConnection("irc.freenode.net:6667", "sprintbot", false, true) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
con.Start() | |
ch := con.Join("#ipfs") | |
participants := []string{"whyrusleeping", "jbenet", "cryptix", "wking", "lgierth", "krl", "kbala_", "rht__", "daviddias", "dPow", "chriscool", "gatesvp"} | |
participantTrigger := &hb.Trigger{ | |
func(mes *hb.Message) bool { | |
return mes.Content == "!sprintpeople" | |
}, | |
func(con *hb.IrcCon, mes *hb.Message) bool { | |
con.Channels[mes.To].Say(fmt.Sprint(participants)) | |
return true | |
}, | |
} | |
con.AddTrigger(participantTrigger) | |
go func() { | |
for { | |
nsp := getNextSprintTime() | |
towait := nsp.Sub(time.Now()) | |
time.Sleep(towait) | |
mes := fmt.Sprintf("Sprint Checkin! %s", participants) | |
ch.Say(mes) | |
} | |
}() | |
for _ = range con.Incoming { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment