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