This commit is contained in:
shoopea 2019-05-15 16:58:25 +08:00
parent 0b14e0d5ce
commit 33aa4ea6dc
3 changed files with 23 additions and 12 deletions

16
def.go
View File

@ -6,6 +6,16 @@ import (
"time"
)
type ChatWarsCommand struct {
Type int64 `json:"type"`
FromChatID64 int64 `json:"from_chat_id"`
FromUserID64 int64 `json:"from_user_id"`
FromMsgID64 int64 `json:"from_msg_id"`
ToChatID64 int64 `json:"to_chat_id"`
ToUserID64 int64 `json:"to_user_id"`
Text string `json:"text"`
}
type ChatWarsMessage struct {
UserID64 int64 `json:"user_id"`
SenderUserID64 int64 `json:"sender_user_id"`
@ -92,6 +102,12 @@ type JobPayloadSetDone struct {
}
const (
commandForwardMsg = 1
commandReplyMsg = 2
commandSendMsg = 3
commandDeleteMsg = 4
commandRefreshMsg = 5
objTypeUser = 1
objTypeGuild = 2
objTypeMessage = 3

6
sql.go
View File

@ -1304,8 +1304,9 @@ func resetMsgParsingRules() {
`.*(?P<Score6>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points6>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score7>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points7>\\+([0-9]+|NaN))\\n` +
`(?s:.*)` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
;`)
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "Pillage Inc", "^You were strolling around on your horse when you noticed (?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village. To stop him click /go$")` +
`;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}
@ -1461,6 +1462,7 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
if err != nil {
return err
}
return nil
}

View File

@ -106,7 +106,9 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgMiniWar")
err = setObjSubTypeId(objId, objSubTypeMessageMiniWar)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(MiniWar)")
case objSubTypeMessagePillageInc:
err = setObjSubTypeId(objId, objSubTypeMessagePillageInc)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageInc)")
case objSubTypeMessageAuctionAnnounce:
cwm := ChatWarsMessageAuctionAnnounce{
ObjID64: objId,
@ -127,15 +129,6 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
err = setObjSubTypeId(objId, objSubTypeMessageAuctionAnnounce)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(AuctionAnnounce)")
case objSubTypeMessageTimeAck:
/*
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Time (%d)\n", objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Time : %s (%d)\n", r.ReplaceAllString(m.Text, "${Time}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Hour : %s (%d)\n", r.ReplaceAllString(m.Text, "${Hour}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Minute : %s (%d)\n", r.ReplaceAllString(m.Text, "${Minute}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Day : %s (%d)\n", r.ReplaceAllString(m.Text, "${Day}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Month : %s (%d)\n", r.ReplaceAllString(m.Text, "${Month}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Year : %s (%d)\n", r.ReplaceAllString(m.Text, "${Year}"), objId)
*/
_, err := fromChatWarsDate(r.ReplaceAllString(m.Text, "${Day}") + " " + r.ReplaceAllString(m.Text, "${Month}") + " " + r.ReplaceAllString(m.Text, "${Year}") + " " + r.ReplaceAllString(m.Text, "${Hour}") + ":" + r.ReplaceAllString(m.Text, "${Minute}"))
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : fromChatWarsDate")
err = setObjSubTypeId(objId, objSubTypeMessageTimeAck)