This commit is contained in:
shoopea 2019-05-26 19:30:21 +08:00
parent 41413bd3ca
commit 720a1c2fb5
2 changed files with 24 additions and 1 deletions

23
bot.go
View File

@ -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<Delay>([0-9]{2}h){0,1}([0-9]{2}m){0,1}([0-9]{2}s){0,1}) \"(?<Msg>(.*))\"$")
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
}

2
msg.go
View File

@ -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<Union>(?s:[^(🎪State of exclusive rights)]*))(🎪State of exclusive rights:)(?P<Fair>(?s:.*))$')
/*
"^(🏠Trade union news:\\n){0,1}` +
`(((?P<Union>[A-Z][a-z]+ [A-Z][a-z]+) was (?P<Status>(easily defended|defended successfully|breached.|easily breached.|closely breached.))(Attackers have pillage union for (?<Loot>[0-9]+) stock):\\n` +