本文整理汇总了Golang中github.com/djosephsen/hustlebot/lib.Broker.QuestionCallback方法的典型用法代码示例。如果您正苦于以下问题:Golang Broker.QuestionCallback方法的具体用法?Golang Broker.QuestionCallback怎么用?Golang Broker.QuestionCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/djosephsen/hustlebot/lib.Broker
的用法示例。
在下文中一共展示了Broker.QuestionCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newQuestion
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: runTest
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)
}