From 720a1c2fb57a70cd42e20066f6e1b0a215da2575 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 26 May 2019 19:30:21 +0800 Subject: [PATCH] testtest --- bot.go | 23 ++++++++++++++++++++++- msg.go | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index 8503d4c..1131a4c 100644 --- a/bot.go +++ b/bot.go @@ -28,6 +28,8 @@ func BotHandlers(b *tb.Bot) { b.Handle("/parse_rules", botListParsingRules) b.Handle("/parse_rule", botListParsingRule) + b.Handle("/timer", botTimer) + b.Handle(tb.OnPhoto, botPhoto) b.Handle(tb.OnChannelPost, botChannelPost) b.Handle(tb.OnQuery, botQuery) @@ -43,7 +45,7 @@ func botPhoto(m *tb.Message) { } func botDocument(m *tb.Message) { - fmt.Printf("botDocument : %s (%d - %s)", m.Document.FileName, m.Document.File.FileSize, m.Document.File.FilePath) + fmt.Printf("botDocument : %s (%d bytes)", m.Document.FileName, m.Document.File.FileSize) // documents only } @@ -266,3 +268,22 @@ func botListParsingRule(m *tb.Message) { } return } + +func botTimer(m *tb.Message) { + var res string + r := regexp.MustCompile("^(?P([0-9]{2}h){0,1}([0-9]{2}m){0,1}([0-9]{2}s){0,1}) \"(?(.*))\"$") + if r.MatchString(m.Payload) { + log.Printf("Timer : Delay : %s\n", r.ReplaceAllString(m.Payload, "${Delay}")) + log.Printf("Timer : Msg : %s\n", r.ReplaceAllString(m.Payload, "${Msg}")) + } + /* + c := TGCommand{ + Type: commandReplyMsg, + Text: res, + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c + */ + return +} diff --git a/msg.go b/msg.go index e63dda7..18e025f 100644 --- a/msg.go +++ b/msg.go @@ -28,6 +28,8 @@ func parseSubTypeMessageReportAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa } func parseSubTypeMessageUnionWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageUnionWar, error) { + //re := regexp.MustCompile('^(🏠Trade union news:\\n)(?P(?s:[^(🎪State of exclusive rights)]*))(🎪State of exclusive rights:)(?P(?s:.*))$') + /* "^(🏠Trade union news:\\n){0,1}` + `(((?P[A-Z][a-z]+ [A-Z][a-z]+) was (?P(easily defended|defended successfully|breached.|easily breached.|closely breached.))(Attackers have pillage union for (?[0-9]+) stock):\\n` +