本文整理汇总了Golang中github.com/src-d/lazlo/lib.Broker类的典型用法代码示例。如果您正苦于以下问题:Golang Broker类的具体用法?Golang Broker怎么用?Golang Broker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Broker类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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:src-d,项目名称:lazlo,代码行数:7,代码来源:qtest.go
示例2: pingRun
func pingRun(b *lazlo.Broker) {
cb := b.MessageCallback(`(?i)(ping|syn)`, true)
for {
pm := <-cb.Chan
pm.Event.Reply(randReply())
}
}
开发者ID:src-d,项目名称:lazlo,代码行数:7,代码来源:ping.go
示例3: helpRun
func helpRun(b *lazlo.Broker) {
cb := b.MessageCallback(`(?i)help`, true)
for {
pm := <-cb.Chan
go getHelp(b, &pm)
}
}
开发者ID:src-d,项目名称:lazlo,代码行数:7,代码来源:help.go
示例4: newLink
func newLink(b *lazlo.Broker, path string, clickChan chan string) string {
link_cb := b.LinkCallback(path)
go func(link_cb *lazlo.LinkCallback, clickChan chan string) {
for {
<-link_cb.Chan
clickChan <- link_cb.Path
}
}(link_cb, clickChan)
return fmt.Sprintf("Ok, <%s|here> is a link on %s", link_cb.URL, path)
}
开发者ID:src-d,项目名称:lazlo,代码行数:10,代码来源:linktest.go
示例5: 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:src-d,项目名称:lazlo,代码行数:12,代码来源:help.go
示例6: newChoice
func newChoice(b *lazlo.Broker, clickChan chan string) string {
opt1 := b.LinkCallback(`option1`)
opt2 := b.LinkCallback(`option2`)
go func(opt1 *lazlo.LinkCallback, opt2 *lazlo.LinkCallback, clickChan chan string) {
for {
select {
case <-opt1.Chan:
clickChan <- `THIS`
case <-opt2.Chan:
clickChan <- `THAT`
}
}
}(opt1, opt2, clickChan)
return fmt.Sprintf("you can get with <%s|THIS> or you can get with <%s|THAT>", opt1.URL, opt2.URL)
}
开发者ID:src-d,项目名称:lazlo,代码行数:15,代码来源:linktest.go
示例7: rtmrun
func rtmrun(b *lazlo.Broker) {
for {
// get a timer callback
timer := b.TimerCallback(`*/20 * * * * * *`)
// block waiting for an alarm from the timer
<-timer.Chan
//send a ping
b.Send(&lazlo.Event{
Type: `ping`,
Text: `just pingin`,
})
}
}
开发者ID:src-d,项目名称:lazlo,代码行数:15,代码来源:rtmping.go
示例8: initModules
func initModules(b *lazlo.Broker) error {
b.Register(modules.Syn)
// b.Register(modules.RTMPing)
b.Register(modules.LinkTest)
b.Register(modules.BrainTest)
b.Register(modules.Help)
b.Register(modules.LuaMod)
b.Register(modules.QuestionTest)
return nil
}
开发者ID:src-d,项目名称:lazlo,代码行数:10,代码来源:loadModules.go
示例9: 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:src-d,项目名称:lazlo,代码行数:12,代码来源:qtest.go
注:本文中的github.com/src-d/lazlo/lib.Broker类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论