Пример #1
0
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
}
Пример #2
0
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
	newStrings := make([]string, len(strings))
	for _, str := range strings {
		newStrings = append(newStrings, res.UserID()+`: `+str)
	}

	a.Send(res, newStrings...)

	return nil
}
Пример #3
0
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
	newStrings := make([]string, len(strings))
	for _, str := range strings {
		newStrings = append(newStrings, fmt.Sprintf("%s: %s", res.UserName(), str))
	}

	a.Send(res, newStrings...)

	return nil
}
Пример #4
0
// Reply sends a direct response
func (a *adapter) Reply(res *hal.Response, strings ...string) error {
	for _, str := range strings {
		s := res.UserName() + `: ` + str
		err := a.writeString(s)
		if err != nil {
			log.Println("error: ", err)
			return err
		}
	}

	return nil
}
Пример #5
0
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
}
Пример #6
0
// Topic sets the topic
func (a *adapter) Topic(res *hal.Response, strings ...string) error {
	for _, str := range strings {
		a.conn.SendRawf("TOPIC %s %s", res.Room(), str)
	}
	return nil
}
Пример #7
0
func (h *ping) Run(res *hal.Response) error {
	return res.Send("PONG")
}