當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Broker.Say方法代碼示例

本文整理匯總了Golang中github.com/djosephsen/lazlo/lib.Broker.Say方法的典型用法代碼示例。如果您正苦於以下問題:Golang Broker.Say方法的具體用法?Golang Broker.Say怎麽用?Golang Broker.Say使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/djosephsen/lazlo/lib.Broker的用法示例。


在下文中一共展示了Broker.Say方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
開發者ID:sharadgana,項目名稱:lazlo,代碼行數:7,代碼來源:qtest.go

示例2: getHelp

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)
}
開發者ID:sharadgana,項目名稱:lazlo,代碼行數:12,代碼來源:help.go

示例3: 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)
}
開發者ID:sharadgana,項目名稱:lazlo,代碼行數:12,代碼來源:qtest.go


注:本文中的github.com/djosephsen/lazlo/lib.Broker.Say方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。