• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang message.MsgPrivate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了MsgPrivate类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: handlePlaceSpecificBet

func handlePlaceSpecificBet(state State, msg message.MsgPrivate) bool {
	ts, err := bet.ParseDate(msg.Msg)
	if err != nil {
		return false
	}
	placeBet(state, msg.Nick(), msg, ts, false)
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:8,代码来源:message_handler.go


示例5: 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


示例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: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: handleMetapi

func handleMetapi(state State, msg message.MsgPrivate) bool {
	log.Printf("Check %s", msg.Msg)
	if !strings.HasPrefix(strings.ToLower(msg.Msg), "metapi") {
		return false
	}
	log.Printf("Passed for %s", msg.Msg)
	num, err := strconv.ParseInt(msg.Msg[7:], 10, 64)
	if err != nil {
		state.ResponseChannel <- message.MsgSend{msg.Response(), fmt.Sprintf("Expect an int32 to search, error was %q", err)}
		return true
	} else {
		state.ResponseChannel <- message.MsgSend{msg.Response(), "Launching big real data time calculation on the claoud"}
		state.PiQueryChannel <- metapi.PiQuery{num, msg.Response()}
	}
	return true
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:16,代码来源:message_handler.go


示例18: closeBet

func closeBet(state State, msg message.MsgPrivate, ts time.Time) {
	winners := bet.CloseBet(state.Db, ts)
	resp := formatWinners(winners, state.Conf)
	state.ResponseChannel <- message.MsgSend{msg.Response(), resp}
}
开发者ID:bonnefoa,项目名称:gobot,代码行数:5,代码来源:message_handler.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang utils.BitList类代码示例发布时间:2022-05-24
下一篇:
Golang bolt.Tx类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap