From 9ec3ec7d7d94891ea4eb2a480ea3e4c1f7320285 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 26 May 2019 20:02:27 +0800 Subject: [PATCH] test --- bot.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bot.go b/bot.go index 2a3f063..df80893 100644 --- a/bot.go +++ b/bot.go @@ -270,11 +270,10 @@ func botListParsingRule(m *tb.Message) { } func botTimer(m *tb.Message) { - r := regexp.MustCompile("^((?P[0-9]{2})h){0,1}((?P[0-9]{2})m){0,1}((?P[0-9]{2})s){0,1} \"(?P(.*))\"$") + r := regexp.MustCompile("^(?P([0-9]*(s|m|h))+) \"(?P(.*))\"$") if r.MatchString(m.Payload) { - log.Printf("Timer : Hour : %s\n", r.ReplaceAllString(m.Payload, "${Hour}")) - log.Printf("Timer : Minute : %s\n", r.ReplaceAllString(m.Payload, "${Minute}")) - log.Printf("Timer : Second : %s\n", r.ReplaceAllString(m.Payload, "${Second}")) + h, _ := strconv.ParseInt(r.ReplaceAllString(m.Payload, "${Hour}"), 10, 32) + log.Printf("Timer : Duration : %s\n", r.ReplaceAllString(m.Payload, "${Duration}")) log.Printf("Timer : Msg : %s\n", r.ReplaceAllString(m.Payload, "${Msg}")) } /*