本文整理汇总了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;未经允许,请勿转载。 |
请发表评论