Skip to content

Instantly share code, notes, and snippets.

@markphelps
Last active November 3, 2016 22:53
Show Gist options
  • Save markphelps/c85d2d20e96a41026e8c2d8c5b765f42 to your computer and use it in GitHub Desktop.
Save markphelps/c85d2d20e96a41026e8c2d8c5b765f42 to your computer and use it in GitHub Desktop.
type chatFn func(b *Bot) chatFn
func (b *Bot) chat() {
for state := hello; state != nil; {
state = state(b)
}
}
func hello(b *Bot) chatFn {
b.send("Hello!")
return wait
}
func wait(b *Bot) chatFn {
time.Sleep(5 * time.Second)
return goodbye;
}
func goodbye(b *Bot) chatFn {
b.send("Goodbye!")
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment