Пример #1
0
func newQuestion(b *lazlo.Broker, req lazlo.PatternMatch) {
	lazlo.Logger.Info("new question")
	qcb := b.QuestionCallback(req.Event.User, req.Match[2])
	answer := <-qcb.Answer
	response := fmt.Sprintf("You answered: '%s'", answer)
	b.Say(response, qcb.DMChan)
}
Пример #2
0
func getHelp(b *lazlo.Broker, pm *lazlo.PatternMatch) {
	dmChan := b.GetDM(pm.Event.User)
	reply := `########## Modules In use: `
	for _, m := range b.Modules {
		if strings.Contains(m.Usage, `%HIDDEN%`) {
			continue
		}
		usage := strings.Replace(m.Usage, `%BOTNAME%`, b.Config.Name, -1)
		reply = fmt.Sprintf("%s\n%s", reply, usage)
	}
	b.Say(reply, dmChan)
}
Пример #3
0
func runTest(b *lazlo.Broker, req lazlo.PatternMatch) {
	dmChan := b.GetDM(req.Event.User)
	user := b.SlackMeta.GetUserName(req.Event.User)
	b.Say(fmt.Sprintf(`hi %s! I'm going to ask you a few questions.`, user), dmChan)
	qcb := b.QuestionCallback(req.Event.User, `what is your name?`)
	name := <-qcb.Answer
	qcb = b.QuestionCallback(req.Event.User, `what is your quest?`)
	quest := <-qcb.Answer
	qcb = b.QuestionCallback(req.Event.User, `what is your favorite color?`)
	color := <-qcb.Answer
	b.Say(fmt.Sprintf(`awesome. you said your name is %s, your quest is %s and your favorite color is %s`, name, quest, color), dmChan)
}