Last active
November 3, 2016 22:53
-
-
Save markphelps/c85d2d20e96a41026e8c2d8c5b765f42 to your computer and use it in GitHub Desktop.
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
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