fix references
This commit is contained in:
parent
306648c830
commit
cd8e1e40f1
@ -50,7 +50,7 @@ func clientRefreshCWMsg(userID64 int64, chatID64 int64, msgID64 int64) {
|
||||
}
|
||||
|
||||
func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
if clt, ok := getLockedClient(m.Msg.UserID64, false); ok {
|
||||
if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok {
|
||||
if clt.Active {
|
||||
if clt.CWLastUpdate.Before(m.Msg.Date) {
|
||||
clt.CWGuildID64 = m.GuildID64
|
||||
@ -58,7 +58,7 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
clt.CWState = m.State
|
||||
clt.CWLastUpdate = m.Msg.Date
|
||||
if getObjGuildID(``) != m.GuildID64 && strings.Compare(clt.CWRole, ``) == 0 {
|
||||
clientSendCWMsg(m.Msg.UserID64, "/g_roles")
|
||||
clientSendCWMsg(m.Msg.TGUserID64, "/g_roles")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
}
|
||||
|
||||
func clientMsgGoQuestAck(m *ChatWarsMessageGoQuestAck) {
|
||||
if clt, ok := getLockedClient(m.Msg.UserID64, false); ok {
|
||||
if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok {
|
||||
if clt.Active {
|
||||
if clt.CWLastUpdate.Before(m.Msg.Date) {
|
||||
clt.CWLastUpdate = m.Msg.Date
|
||||
@ -79,7 +79,7 @@ func clientMsgGoQuestAck(m *ChatWarsMessageGoQuestAck) {
|
||||
}
|
||||
|
||||
func clientMsgGRolesAck(m *ChatWarsMessageGRolesAck) {
|
||||
if clt, ok := getLockedClient(m.Msg.UserID64, false); ok {
|
||||
if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok {
|
||||
if clt.Active {
|
||||
if clt.CWLastUpdate.Before(m.Msg.Date) {
|
||||
if m.CommanderID64 == clt.CWUserID64 {
|
||||
|
14
def.go
14
def.go
@ -109,13 +109,13 @@ type ChatWarsMessageReportAck struct {
|
||||
}
|
||||
|
||||
type ChatWarsMessageMeAck struct {
|
||||
Msg *ChatWarsMessage `json:"msg"`
|
||||
UserID64 int64 `json:"user_id"`
|
||||
GuildID64 int64 `json:"guild_id"`
|
||||
State string `json:"state"`
|
||||
Level int64 `json:"level"`
|
||||
ExpNow int64 `json:"exp_now"`
|
||||
ExpLvl int64 `json:"exp_lvl"`
|
||||
Msg *ChatWarsMessage `json:"msg"`
|
||||
CWUserID64 int64 `json:"user_id"`
|
||||
CWGuildID64 int64 `json:"guild_id"`
|
||||
State string `json:"state"`
|
||||
Level int64 `json:"level"`
|
||||
ExpNow int64 `json:"exp_now"`
|
||||
ExpLvl int64 `json:"exp_lvl"`
|
||||
}
|
||||
|
||||
type ChatWarsMessageGRolesAck struct {
|
||||
|
2
job.go
2
job.go
@ -430,7 +430,7 @@ func jobMsgRefresh(j Job) {
|
||||
err = delObj(p.ObjID64)
|
||||
logOnError(err, "jobMsgRefresh : delObj")
|
||||
|
||||
clientRefreshCWMsg(m.UserID64, m.ChatID64, m.ID64)
|
||||
clientRefreshCWMsg(m.TGUserID64, m.ChatID64, m.ID64)
|
||||
|
||||
err = setJobDone(j.ID64)
|
||||
logOnError(err, "joMsgClient : setJobDone")
|
||||
|
6
msg.go
6
msg.go
@ -75,9 +75,9 @@ func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMe
|
||||
var i int64
|
||||
|
||||
cwm := ChatWarsMessageMeAck{
|
||||
UserID64: getObjUserID(r.ReplaceAllString(m.Text, "${Player}")),
|
||||
GuildID64: getObjGuildID(r.ReplaceAllString(m.Text, "${Guild}")),
|
||||
State: r.ReplaceAllString(m.Text, "${State}"),
|
||||
CWUserID64: getObjUserID(r.ReplaceAllString(m.Text, "${Player}")),
|
||||
CWGuildID64: getObjGuildID(r.ReplaceAllString(m.Text, "${Guild}")),
|
||||
State: r.ReplaceAllString(m.Text, "${State}"),
|
||||
}
|
||||
i, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ExpNow}"), 10, 64)
|
||||
cwm.ExpNow = i
|
||||
|
10
obj.go
10
obj.go
@ -76,7 +76,7 @@ func objAddName(objID64 int64, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUserID64 int64, msgDate time.Time, msgText string) (int64, error) {
|
||||
func addObjMsg(msgID64 int64, msgChatID64 int64, msgTGUserID64 int64, msgTGSenderUserID64 int64, msgDate time.Time, msgText string) (int64, error) {
|
||||
tx, err := db.Begin()
|
||||
logOnError(err, "addObjMsg : start transaction")
|
||||
if err != nil {
|
||||
@ -107,7 +107,7 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
_, err = stmt.Exec(objId, msgID64, msgChatID64, msgUserID64, msgSenderUserID64, msgDate, msgText)
|
||||
_, err = stmt.Exec(objId, msgID64, msgChatID64, msgTGUserID64, msgTGSenderUserID64, msgDate, msgText)
|
||||
if err != nil {
|
||||
err2 := tx.Rollback()
|
||||
logOnError(err2, "addObjMsg : rollback exec insert obj_msg")
|
||||
@ -121,8 +121,8 @@ func addObjMsg(msgID64 int64, msgChatID64 int64, msgUserID64 int64, msgSenderUse
|
||||
|
||||
m := new(ChatWarsMessage)
|
||||
m.ObjID64 = objId
|
||||
m.UserID64 = msgUserID64
|
||||
m.SenderUserID64 = msgSenderUserID64
|
||||
m.TGUserID64 = msgTGUserID64
|
||||
m.SenderUserID64 = msgTGSenderUserID64
|
||||
m.Date = msgDate
|
||||
m.ID64 = msgID64
|
||||
m.ChatID64 = msgChatID64
|
||||
@ -148,7 +148,7 @@ func getObjMsg(objId int64) (*ChatWarsMessage, error) {
|
||||
|
||||
m = new(ChatWarsMessage)
|
||||
|
||||
err = stmt.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.UserID64, &m.SenderUserID64, &m.Date, &m.Text)
|
||||
err = stmt.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.TGUserID64, &m.TGSenderUserID64, &m.Date, &m.Text)
|
||||
if err != nil {
|
||||
return m, err
|
||||
}
|
||||
|
12
workers.go
12
workers.go
@ -309,7 +309,7 @@ func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
|
||||
func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
|
||||
//log.Printf("SQLCWMsgWorker[" + strconv.Itoa(id) + "] : Starting.")
|
||||
for m := range msgs {
|
||||
objId, err := addObjMsg(m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
|
||||
objId, err := addObjMsg(m.ID64, m.ChatID64, m.TGUserID64, m.TGSenderUserID64, m.Date, m.Text)
|
||||
logOnError(err, "SQLCWMsgWorker["+strconv.Itoa(id)+"] : Inserting message.")
|
||||
if err == nil && objId != 0 {
|
||||
// log.Printf("SQLCWMsgWorker["+strconv.Itoa(id)+"] : Message inserted (%d).\n", objId)
|
||||
@ -394,14 +394,14 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("Catching pillage (%s)", m.Date.Format(time.RFC3339)),
|
||||
ToUserID64: m.UserID64,
|
||||
ToUserID64: m.TGUserID64,
|
||||
}
|
||||
TGCmdQueue <- s
|
||||
p := JobPayloadPillage{
|
||||
ObjID64: objId,
|
||||
}
|
||||
b, _ := json.Marshal(&p)
|
||||
_, err = createJob(objSubTypeJobPillage, objJobPriority, m.UserID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
||||
_, err = createJob(objSubTypeJobPillage, objJobPriority, m.TGUserID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
|
||||
}
|
||||
case objSubTypeMessageMeAck:
|
||||
@ -409,13 +409,13 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMeAck.")
|
||||
cwm.Msg = m
|
||||
clientMsgMeAck(cwm)
|
||||
_, err = addObjXP(cwm.UserID64, cwm.ExpNow, cwm.ExpLvl, cwm.Level, m.Date)
|
||||
_, err = addObjXP(cwm.CWUserID64, cwm.ExpNow, cwm.ExpLvl, cwm.Level, m.Date)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : addObjXP(MeAck)")
|
||||
case objSubTypeMessageGoQuestAck:
|
||||
cwm, err := parseSubTypeMessageGoQuestAck(m, r)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageGoQuestAck.")
|
||||
cwm.Msg = m
|
||||
uid, err := clientGetCWUserID64(m.UserID64)
|
||||
uid, err := clientGetCWUserID64(m.TGUserID64)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving UserID64.")
|
||||
if err != nil {
|
||||
err = setObjSubTypeId(objId, objSubTypeMessageUnknown)
|
||||
@ -448,7 +448,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
ObjID64: m.ObjID64,
|
||||
}
|
||||
b, _ := json.Marshal(&p)
|
||||
_, err = createJob(objSubTypeJobMsgRefresh, objJobPriority, m.UserID64, cwm.End.Add(5*time.Minute).UTC(), b)
|
||||
_, err = createJob(objSubTypeJobMsgRefresh, objJobPriority, m.TGUserID64, cwm.End.Add(5*time.Minute).UTC(), b)
|
||||
}
|
||||
case objSubTypeMessageTimeAck:
|
||||
_, 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}"))
|
||||
|
Loading…
Reference in New Issue
Block a user