Пример #1
0
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
}
Пример #2
0
func handleAdminBet(state State, msg message.MsgPrivate) bool {
	if strings.ToLower(msg.User) != state.Conf.Admin {
		return false
	}
	splitted := strings.Split(msg.Msg, " ")
	if len(splitted) == 0 {
		return false
	}
	ts, err := bet.ParseDate(strings.Join(splitted[:len(splitted)-1], " "))
	if err != nil {
		return false
	}
	nick := splitted[len(splitted)-1]
	placeBet(state, nick, msg, ts, true)
	return true
}
Пример #3
0
func parseTimezoneQuery(query string) (time.Time, error) {
	var err error
	var ts time.Time
	ts = time.Now()
	splitted := strings.Split(query, " ")
	if len(splitted) < 3 {
		return ts, errors.New("Too small")
	}
	possibleDate := strings.Join(splitted[:len(splitted)-2], " ")
	log.Printf("Possible date %s", possibleDate)
	ts, err = bet.ParseDate(possibleDate)
	if err != nil {
		return ts, err
	}
	locationStr := splitted[len(splitted)-1]
	fmt.Printf("Location is %s\n", locationStr)
	location, err := time.LoadLocation(locationStr)
	if err != nil {
		return ts, err
	}
	return ts.In(location), err
}