Closed zpatrick closed 6 years ago
Note that there may already be something in the stdlib for this, but I couldn't find anything after a brief search.
Most !commands end their functions like this:
text := "Ok, I did the thing" if _, err := w.Write([]byte(text)); err != nil { return err } return nil
We should add some helper functions to the bot package:
bot
// file: slackbot/bot/utils.go func write(w io.Writer, text string) error { if _, err := w.Write([]byte(text)); err != nil { return err } return nil } func writef(w io.Writer, format string, tokens ...interface{}) error { return write(w, fmt.Sprintf(format, tokens...) }
Then, we should update our !commands to look like this:
return write(w, "Ok, I did the thing")
closed by #42
Note that there may already be something in the stdlib for this, but I couldn't find anything after a brief search.
Most !commands end their functions like this:
We should add some helper functions to the
bot
package:Then, we should update our !commands to look like this: