update ambush

This commit is contained in:
shoopea 2019-10-20 20:28:16 +08:00
parent 749979b593
commit 0338338c14
3 changed files with 22 additions and 11 deletions

2
def.go
View File

@ -208,7 +208,7 @@ type ChatWarsMessageQuestResult struct {
type ChatWarsMessageQuestResultAmbush struct {
Msg *ChatWarsMessage `json:"msg"`
Loot []ChatWarsItems `json:"loot"`
Level int `json:"level"`
Level int64 `json:"level"`
Armored bool `json:"armored"`
Enraged bool `json:"enraged"`
SpearResists bool `json:"spear resists"`

11
msg.go
View File

@ -428,7 +428,7 @@ func parseSubTypeMessageDuelFight(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
}
func parseSubTypeMessageQuestResultAmbush(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageQuestResultAmbush, error) {
var level float64
var lvlSum, qtySum int64
cwm := ChatWarsMessageQuestResultAmbush{}
@ -446,9 +446,16 @@ func parseSubTypeMessageQuestResultAmbush(m *ChatWarsMessage, r *regexp.Regexp)
}
lvl, _ := strconv.ParseInt(l[4], 10, 64)
log.Printf("parseSubTypeMessageQuestResultAmbush : lvl : %d\n", lvl)
level = level + float64(lvl*qty)
lvlSum = lvlSum + lvl
qtySum = qtySum + qty
}
cwm.Level = lvlSum / qtySum
cwm.Msg = m
log.Printf("parseSubTypeMessageQuestResultAmbush : Level : %d\n", cwm.Level)
return &cwm, nil
}

View File

@ -386,15 +386,19 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case objSubTypeMessageQuestResultAmbush:
_, err := parseSubTypeMessageQuestResultAmbush(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageQuestResultAmbush.")
if m.Date.Add(3*time.Minute).After(time.Now()) && m.ChatID64 == chtwrsbotID64 {
s := TGCommand{
Type: commandForwardMsg,
FromUserID64: m.TGUserID64,
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
ToChatID64: cfg.Bot.Mainchat,
if m.Date.Add(3 * time.Minute).After(time.Now().UTC()) {
if m.ChatID64 == chtwrsbotID64 {
s := TGCommand{
Type: commandForwardMsg,
FromUserID64: m.TGUserID64,
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
ToChatID64: cfg.Bot.Mainchat,
}
MQTGCmdQueue <- s
} else if m.ChatID64 == cfg.Bot.Mainchat {
}
MQTGCmdQueue <- s
}
case objSubTypeMessagePillageInc:
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)