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


Golang MsgPrivate.Response方法代码示例

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


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

示例1: handleRotate

func handleRotate(state State, msg message.MsgPrivate) bool {
	if !strings.HasPrefix(strings.ToLower(msg.Msg), "rotate") {
		return false
	}
	state.ResponseChannel <- message.MsgSend{msg.Response(), bstrings.RotateString(msg.Msg[6:])}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:7,代码来源:message_handler.go

示例2: handleHelp

func handleHelp(state State, msg message.MsgPrivate) bool {
	if strings.ToLower(msg.Msg) != "gobot: help" {
		return false
	}
	state.ResponseChannel <- message.MsgSend{msg.Response(), state.Conf.Help}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:7,代码来源:message_handler.go

示例3: handleTimezoneConversion

func handleTimezoneConversion(state State, msg message.MsgPrivate) bool {
	ts, err := parseTimezoneQuery(msg.Msg)
	if err != nil {
		return false
	}
	state.ResponseChannel <- message.MsgSend{msg.Response(), ts.String()}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:8,代码来源:message_handler.go

示例4: handleTroll

func handleTroll(state State, msg message.MsgPrivate) bool {
	if !strings.HasPrefix(strings.ToLower(msg.Msg), "troll") {
		return false
	}
	winners := []string{msg.Nick()}
	resp := formatWinners(winners, state.Conf)
	state.ResponseChannel <- message.MsgSend{msg.Response(), resp}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:9,代码来源:message_handler.go

示例5: handleDodo

func handleDodo(state State, msg message.MsgPrivate) bool {
	if !strings.Contains(strings.ToLower(msg.Msg), "dodo") {
		return false
	}
	zStr := strings.Repeat("Zz", rand.Intn(25))
	res := bstrings.ColorStringSlice(bstrings.ShuffleString(zStr))
	nick := getNickInMessage(state.Db, msg.Msg)
	state.ResponseChannel <- message.MsgSend{msg.Response(), fmt.Sprintf("%s%s", nick, res)}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:10,代码来源:message_handler.go

示例6: placeBet

func placeBet(state State, nick string, msg message.MsgPrivate, ts time.Time, isAdmin bool) {
	err := bet.AddUserBet(state.Db, nick, ts, isAdmin)
	if err == nil {
		ts_str := fmt.Sprintf("Za dude %s placed bet for %s", nick, ts.Format(time.RFC1123Z))
		state.ResponseChannel <- message.MsgSend{msg.Response(), ts_str}
	} else {
		ts_str := fmt.Sprintf("Hey %s, %s", nick, err)
		state.ResponseChannel <- message.MsgSend{msg.Response(), ts_str}
	}
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:10,代码来源:message_handler.go

示例7: handleReset

func handleReset(state State, msg message.MsgPrivate) bool {
	if strings.ToLower(msg.Msg) != "reset" {
		return false
	}
	if strings.ToLower(msg.User) != state.Conf.Admin {
		return false
	}
	bet.ResetBet(state.Db)
	state.ResponseChannel <- message.MsgSend{msg.Response(), "I have reset the bet, master."}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:11,代码来源:message_handler.go

示例8: handleBetSpecificTimeZone

func handleBetSpecificTimeZone(state State, msg message.MsgPrivate) bool {
	if !strings.HasPrefix(strings.ToLower(msg.Msg), "bet") {
		return false
	}
	location, err := time.LoadLocation(msg.Msg[4:])
	if err != nil {
		state.ResponseChannel <- message.MsgSend{msg.Response(), "Invalid timezone dude"}
	} else {
		printBet(state, location, msg)
	}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:12,代码来源:message_handler.go

示例9: printSpecificBet

func printSpecificBet(state State, betId int, location *time.Location, msg message.MsgPrivate) {
	bets := bet.GetUserBets(state.Db, betId)
	nicks := make([]string, len(bets))
	for _, bet := range bets {
		nicks = append(nicks, bet.String())
	}
	maxSize := getMaxNickLength(nicks)
	for _, userBet := range bets {
		resp := fmt.Sprintf("%*s %s", maxSize, userBet.Nick, userBet.Time.In(location))
		state.ResponseChannel <- message.MsgSend{msg.Response(), resp}
	}
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:12,代码来源:message_handler.go

示例10: handlePutf8

func handlePutf8(state State, msg message.MsgPrivate) bool {
	if !strings.Contains(strings.ToLower(msg.Msg), "putf8") {
		return false
	}
	numChars := rand.Intn(25)
	res := make([]string, numChars)
	for i := 0; i < numChars; i++ {
		res[i] = bstrings.ColorString(bstrings.GetRandUtf8())
	}
	nick := getNickInMessage(state.Db, msg.Msg)
	state.ResponseChannel <- message.MsgSend{msg.Response(), fmt.Sprintf("%s%s", nick, strings.Join(res, " "))}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:13,代码来源:message_handler.go

示例11: handleMeteo

func handleMeteo(state State, msg message.MsgPrivate) bool {
	lowerMsg := strings.ToLower(msg.Msg)
	if lowerMsg == "meteo" || lowerMsg == "météo" {
		weather, err := meteo.FetchWeatherFromUrl(state.Conf.Meteo.Url)
		if err != nil {
			log.Printf("Erro on fetch weather : %q", err)
			return true
		}
		log.Printf("Fetched %q", weather)
		state.ResponseChannel <- message.MsgSend{msg.Response(), strings.Join(weather, "|")}
		return true
	}
	return false
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:14,代码来源:message_handler.go

示例12: handleScores

func handleScores(state State, msg message.MsgPrivate) bool {
	if strings.ToLower(msg.Msg) != "scores" {
		return false
	}
	scores := bet.GetScores(state.Db)
	nicks := make([]string, len(scores))
	for _, score := range scores {
		nicks = append(nicks, score.String())
	}
	maxSize := getMaxNickLength(nicks)

	for _, v := range scores {
		resp := fmt.Sprintf("%*s %d", maxSize, v.Nick, v.Score)
		state.ResponseChannel <- message.MsgSend{msg.Response(), resp}
	}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:17,代码来源:message_handler.go

示例13: handleTrigger

func handleTrigger(state State, msg message.MsgPrivate, trigger Trigger) bool {
	lowerMsg := strings.ToLower(msg.Msg)
	lowerMsg = strings.Map(bstrings.KeepLettersAndSpace, lowerMsg)
	if !bstrings.TriggerIn(trigger.Words, lowerMsg) {
		return false
	}
	resp := ""
	nick := getNickInMessage(state.Db, msg.Msg)
	resp = pickMessage(trigger)
	lines := strings.Split(resp, "\n")
	for _, l := range lines {
		if l != "" {
			state.ResponseChannel <- message.MsgSend{msg.Response(), fmt.Sprintf("%s%s", nick, l)}
		}
	}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:17,代码来源:message_handler.go

示例14: handleBsTraining

func handleBsTraining(state State, msg message.MsgPrivate) bool {
	lowerMsg := strings.ToLower(msg.Msg)
	if lowerMsg == "bsreload" {
		state.BsQueryChannel <- bsmeter.BsQuery{IsReload: true}
		return true
	}
	if !strings.HasPrefix(lowerMsg, "bs") && !strings.HasPrefix(lowerMsg, "nobs") {
		return false
	}
	bs := strings.HasPrefix(lowerMsg, "bs")
	urls := html.ExtractUrls(msg.Msg)
	if len(urls) == 0 {
		state.BsQueryChannel <- bsmeter.BsQuery{
			Phrase:     removeFirstWord(lowerMsg),
			IsTraining: true, Bs: bs, Channel: msg.Response()}
	} else {
		state.BsQueryChannel <- bsmeter.BsQuery{Urls: urls,
			IsTraining: true, Bs: bs, Channel: msg.Response()}
	}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:21,代码来源:message_handler.go

示例15: handleBsRequest

func handleBsRequest(state State, msg message.MsgPrivate) bool {
	lowerMsg := strings.ToLower(msg.Msg)
	bsQuery := bsmeter.BsQuery{Channel: msg.Response()}
	hasBsQuery := strings.HasPrefix(lowerMsg, "isbs")
	hasHttp := strings.Contains(lowerMsg, "http")
	if hasHttp {
		urls := html.ExtractUrls(msg.Msg)
		bsQuery.Urls = urls
	}
	if hasBsQuery {
		phrase := removeFirstWord(lowerMsg)
		for _, url := range bsQuery.Urls {
			phrase = strings.Replace(phrase, url, "", -1)
		}
		bsQuery.Phrase = phrase
	}
	if hasHttp || hasBsQuery {
		state.BsQueryChannel <- bsQuery
		return true
	}
	return false
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:22,代码来源:message_handler.go


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