From 35f6359d1f7eec467b12694df87627ee17ac1eee Mon Sep 17 00:00:00 2001 From: shoopea Date: Tue, 9 Jul 2019 15:12:03 +0800 Subject: [PATCH] test --- README.md | 4 +++- client.go | 11 +++++++++++ workers.go | 9 +++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a3c0333..aa5f89e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ChirpNestBot - [ ] Vault valuation - [ ] Experience graphs & forecast - [ ] Impersonate +- [ ] Link TelegramUserID and UserID - [x] Foray interception - [x] Export/import all messages - [x] Test HTML in message @@ -30,4 +31,5 @@ ChirpNestBot - [x] Rewrite MQ connection handling for clients/keep alive/msg recv - Progression : - 0 -> 4 : Forest + Foray ; - - 5 -> 20 : Forest + Foray + Arena ; \ No newline at end of file + - 5 -> 19 : Forest + Foray + Arena ; + - 20 -> .. : Forest + Swamp + Valley + Foray + Arena. \ No newline at end of file diff --git a/client.go b/client.go index eaa6fa6..92d32f0 100644 --- a/client.go +++ b/client.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "strings" "time" @@ -115,3 +116,13 @@ func clientMsgGRolesAck(m *ChatWarsMessageGRolesAck) { } } } + +func clientGetUserID64(tgUserID64 int64) (int64, error) { + if _, ok := clientsQueue[tgUserID64]; ok { + if v, ok := clientsCW.Load(tgUserID64); ok { + c := v.(*ChatWarsClient) + return c.UserID64, nil + } + } + return 0, errors.New("Unknown user_id.") +} diff --git a/workers.go b/workers.go index 48239c2..967b7e8 100644 --- a/workers.go +++ b/workers.go @@ -400,8 +400,13 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) { cwm, err := parseSubTypeMessageGoQuestAck(m, r) logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMeAck.") cwm.Msg = m - clientMsgGoQuestAck(cwm) - _, err = addObjQuest(m.UserID64, cwm.QuestTypeID, cwm.Duration, m.Date.UTC()) + uid, err := clientGetUserID64(cwm.UserID64) + if err != nil { + err = setObjSubTypeId(objId, objSubTypeMessageUnknown) + } else { + clientMsgGoQuestAck(cwm) + _, err = addObjQuest(cwm.UserID64, cwm.QuestTypeID, cwm.Duration, m.Date.UTC()) + } case objSubTypeMessageDuelFight: cwm, err := parseSubTypeMessageDuelFight(m, r) logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageDuelFight.")