test
This commit is contained in:
parent
9868acd014
commit
2c0b361edd
29
client.go
29
client.go
@ -16,8 +16,8 @@ func clientSendCWMsg(userID64 int64, s string) {
|
||||
|
||||
func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
if _, ok := clientsQueue[m.Msg.UserID64]; ok {
|
||||
if c, ok := clientsCW[m.UserID64]; ok {
|
||||
if c.LastUpdate.Before(m.Msg.Date) {
|
||||
if c, ok := clientsCW[m.Msg.UserID64]; ok {
|
||||
if c.LastUserUpdate.Before(m.Msg.Date) {
|
||||
c.GuildID64 = m.GuildID64
|
||||
c.State = m.State
|
||||
c.LastUpdate = m.Msg.Date
|
||||
@ -27,14 +27,37 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
}
|
||||
} else {
|
||||
c := ChatWarsClient{
|
||||
UserID64: m.UserID64,
|
||||
TelegramID64: m.Msg.UserID64,
|
||||
GuildID64: m.GuildID64,
|
||||
State: m.State,
|
||||
LastUpdate: m.Msg.Date,
|
||||
}
|
||||
clientsCW[m.UserID64] = &c
|
||||
clientsCW[m.Msg.UserID64] = &c
|
||||
if cacheObjGuild[``].ObjID64 != m.GuildID64 {
|
||||
clientSendCWMsg(m.Msg.UserID64, "/g_roles")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func clientMsgGRolesAck(m *ChatWarsMessageGRolesAck) {
|
||||
if _, ok := clientsQueue[m.Msg.UserID64]; ok {
|
||||
if c, ok := clientsCW[m.Msg.UserID64]; ok {
|
||||
if c.LastUpdate.Before(m.Msg.Date) {
|
||||
if m.CommanderID64 == c.UserID64 {
|
||||
c.Role = `commander`
|
||||
} else if m.BartenderID64 == c.UserID64 {
|
||||
c.Role = `bartender`
|
||||
} else if m.SquireID64 == c.UserID64 {
|
||||
c.Role = `squire`
|
||||
} else if m.TreasurerID64 == c.UserID64 {
|
||||
c.Role = `treasurer`
|
||||
} else {
|
||||
c.role = `none`
|
||||
}
|
||||
c.LastUpdate = m.Msg.Date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
def.go
1
def.go
@ -23,6 +23,7 @@ type MQClient struct {
|
||||
|
||||
type ChatWarsClient struct {
|
||||
UserID64 int64 `json:"user_id"`
|
||||
TelegramID64 int64 `json:"telegram_id"`
|
||||
GuildID64 int64 `json:"guild_id"`
|
||||
Role string `json:"role"`
|
||||
State string `json:"state"`
|
||||
|
2
msg.go
2
msg.go
@ -100,6 +100,7 @@ func parseSubTypeMessageGRolesAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
|
||||
} else {
|
||||
cwm.TreasurerID64 = 0
|
||||
}
|
||||
/*
|
||||
log.Printf("parseSubTypeMessageGRolesAck : Guild roles Ack identified\n")
|
||||
log.Printf("parseSubTypeMessageGRolesAck : Bartender : %s\n", r.ReplaceAllString(m.Text, "${Bartender}"))
|
||||
log.Printf("parseSubTypeMessageGRolesAck : Commander : %s\n", r.ReplaceAllString(m.Text, "${Commander}"))
|
||||
@ -109,6 +110,7 @@ func parseSubTypeMessageGRolesAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
|
||||
log.Printf("cwm.CommanderID64 : %d\n", cwm.CommanderID64)
|
||||
log.Printf("cwm.SquireID64 : %d\n", cwm.SquireID64)
|
||||
log.Printf("cwm.TreasurerID64 : %d\n", cwm.TreasurerID64)
|
||||
*/
|
||||
return &cwm, nil
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
case objSubTypeMessageGRolesAck:
|
||||
cwm, err := parseSubTypeMessageGRolesAck(m, r)
|
||||
cwm.Msg = m
|
||||
clientMsgGRolesAck(cwm)
|
||||
err = setObjSubTypeId(objId, objSubTypeMessageGRolesAck)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GRolesAck)")
|
||||
case objSubTypeMessageAuctionAnnounce:
|
||||
|
Loading…
Reference in New Issue
Block a user