update ambush
This commit is contained in:
parent
41a80e2e3e
commit
7549e4956b
12
def.go
12
def.go
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
const maxUnixTimestamp int64 = 2147483647
|
||||
const chtwrsbotID64 int64 = 408101137
|
||||
|
||||
type DataBackup struct {
|
||||
Messages []ChatWarsMessage `json:"messages"`
|
||||
@ -204,6 +205,17 @@ type ChatWarsMessageQuestResult struct {
|
||||
LostTorch bool `json:"lost_torch"`
|
||||
}
|
||||
|
||||
type ChatWarsMessageQuestResultAmbush struct {
|
||||
Msg *ChatWarsMessage `json:"msg"`
|
||||
Loot []ChatWarsItems `json:"loot"`
|
||||
Level int `json:"level"`
|
||||
Armored bool `json:"armored"`
|
||||
Enraged bool `json:"enraged"`
|
||||
SpearResists bool `json:"spear resists"`
|
||||
Toughness bool `json:"toughness"`
|
||||
PoisonBottles bool `json:"poison_bottles"`
|
||||
}
|
||||
|
||||
type ChatWarsMessageDuelFight struct {
|
||||
ObjID64 int64 `json:"obj_id"`
|
||||
WinCastle string `json:"win_castle"`
|
||||
|
11
msg.go
11
msg.go
@ -427,6 +427,17 @@ func parseSubTypeMessageDuelFight(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
|
||||
return &cwm, nil
|
||||
}
|
||||
|
||||
func parseSubTypeMessageQuestResultAmbush(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageQuestResultAmbush, error) {
|
||||
cwm := ChatWarsMessageQuestResultAmbush{}
|
||||
|
||||
re := regexp.MustCompile(`(([0-9] x ){0,1}[a-zA-Z ]* lvl\.[0-9]*)`)
|
||||
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Monsters}"), -1) {
|
||||
log.Printf("parseSubTypeMessageQuestResultAmbush : %s\n", l[1])
|
||||
}
|
||||
cwm.Msg = m
|
||||
return &cwm, nil
|
||||
}
|
||||
|
||||
func parseSubTypeMessagePillageInc(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessagePillageInc, error) {
|
||||
cwm := ChatWarsMessagePillageInc{}
|
||||
cwm.Attacker = r.ReplaceAllString(m.Text, "${Attacker}")
|
||||
|
16
workers.go
16
workers.go
@ -383,6 +383,20 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
cwm, err := parseSubTypeMessageReportAck(m, rule.re)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageReportAck.")
|
||||
cwm.ObjID64 = objId
|
||||
case objSubTypeMessageQuestResultAmbush:
|
||||
cwm, err := parseSubTypeMessageQuestResultAmbush(m, rule.re)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageQuestResultAmbush.")
|
||||
cwm.ObjID64 = objId
|
||||
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,
|
||||
}
|
||||
MQTGCmdQueue <- s
|
||||
}
|
||||
case objSubTypeMessagePillageInc:
|
||||
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessagePillageInc.")
|
||||
@ -390,7 +404,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
err = insertMsgPillageInc(cwm)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
|
||||
// only catch live pillages
|
||||
if m.Date.Add(3 * time.Minute).After(time.Now()) {
|
||||
if m.Date.Add(3*time.Minute).After(time.Now()) && m.ChatID64 == chtwrsbotID64 {
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
||||
|
Loading…
Reference in New Issue
Block a user