示例#1
0
文件: brain.go 项目: dgrijalva/victor
func (self *Brain) registerDefaultAbilities() {
	self.Respond("ping", func(msg *TextMessage) {
		msg.Send("Pong!")
	})

	self.Respond("(image|img) (.*)", func(msg *TextMessage) {
		result, err := google.ImageSearch(msg.Matches()[3])

		if err != nil {
			log.Print(err)
			return
		}

		if result == "" {
			msg.Send("I didn't find anything.")
			return
		}

		msg.Send(result)
	})

	self.Respond("(list|show) users", func(msg *TextMessage) {
		list := ""
		for _, user := range self.users {
			list += user.Name + "\n"
		}

		msg.Paste(list)
	})
}
示例#2
0
文件: robot.go 项目: bketelsen/victor
func (self *Robot) registerDefaultAbilities() {
	self.Respond("ping", func(msg *TextMessage) {
		msg.Send("Pong!")
	})

	self.Respond("(image|img) (.*)", func(msg *TextMessage) {
		result, err := google.ImageSearch(msg.Matches()[3])

		if err != nil {
			log.Print(err)
			return
		}

		if result == "" {
			msg.Send("I didn't find anything.")
			return
		}

		msg.Send(result)
	})
}