Пример #1
0
func Echo(msgIn lonelycat.MessageIn, lc *lonelycat.LonelyCat) error {
	if !strings.HasPrefix(msgIn.Msg, "!echo ") {
		return lonelycat.ErrMsgBadSyntax
	}
	parts := strings.SplitN(msgIn.Msg, " ", 2)
	lc.Say(msgIn.Source, strings.TrimSpace(parts[1]))
	return nil
}
Пример #2
0
func Die(msgIn lonelycat.MessageIn, lc *lonelycat.LonelyCat) error {
	if msgIn.Msg != "die" {
		return lonelycat.ErrMsgBadSyntax
	}
	lc.Say(msgIn.Source, "Bye!")
	lc.Quit()
	return nil
}
Пример #3
0
func Help(msgIn lonelycat.MessageIn, lc *lonelycat.LonelyCat) error {
	if msgIn.Msg != "!help" {
		return lonelycat.ErrMsgBadSyntax
	}
	lc.Say(msgIn.Source, "I'm just a lonely cat who talks about art.")
	lc.Say(msgIn.Source, "Meow!")
	return nil
}
Пример #4
0
func MarkAllNotificationsRead(msgIn lonelycat.MessageIn, lc *lonelycat.LonelyCat) error {
	if msgIn.Msg != "!notifications read" {
		return lonelycat.ErrMsgBadSyntax
	}
	err := lc.Trello.MarkAllNotificationsRead()
	if err != nil {
		return err
	}
	lc.Say(msgIn.Source, "Done.")
	return nil
}
Пример #5
0
func RegisterHandlers(lc *lonelycat.LonelyCat) {
	lc.AddHandler(Die)
	lc.AddHandler(MarkAllNotificationsRead)
	lc.AddHandler(Echo)
	lc.AddHandler(Help)
}