当前位置: 首页>>代码示例>>Golang>>正文


Golang Response.Send方法代码示例

本文整理汇总了Golang中github.com/djosephsen/hal.Response.Send方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.Send方法的具体用法?Golang Response.Send怎么用?Golang Response.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/djosephsen/hal.Response的用法示例。


在下文中一共展示了Response.Send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Run

func (h *ikr) Run(res *hal.Response) error {
	now := time.Now()
	rand.Seed(int64(now.Unix()))
	//only fire half the time
	if rand.Intn(100) >= 50 {
		return nil
	}
	replies := []string{
		"*I know right?!*",
		"*OMG* couldn't agree more",
		":+1:",
		"+1",
		":arrow_up: THAT",
		":arrow_up: you complete me :arrow_up:",
		"so true",
		"agreed.",
		"that's the fact jack",
		"YUUUUUUP",
		"that's what I'm talkin bout",
		"*IKR?!*",
		"singit",
		"^droppin the truth bombs :boom: :boom: :boom:",
		"#legit",
		"/me nodds emphatically in agreement",
		"for REALZ though",
		"FOR REALSIES",
		"it's like you *literally* just read my mind right now",
	}

	reply := replies[rand.Intn(len(replies)-1)]
	hal.Logger.Debug(" *** ikr:Sending response: %s", reply)
	res.Send(reply)
	return nil
}
开发者ID:mjbrender,项目名称:hustlebot,代码行数:34,代码来源:ikr.go

示例2: ExampleHandler_hear

func ExampleHandler_hear() {
	res := hal.Response{
		Match: []string{},
	}
	h := &hal.Handler{
		Method:  hal.HEAR,
		Pattern: `echo (.+)`,
		Usage:   "echo <string> - repeats <string> back",
		Run: func(res *hal.Response) error {
			res.Send(res.Match[1])
		},
	}
	// output:
	// > echo foo bar baz
	// foo bar baz
}
开发者ID:mjbrender,项目名称:hustlebot,代码行数:16,代码来源:handler_test.go

示例3: Run

func (h *ping) Run(res *hal.Response) error {
	return res.Send("PONG")
}
开发者ID:mjbrender,项目名称:hustlebot,代码行数:3,代码来源:ping.go


注:本文中的github.com/djosephsen/hal.Response.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。