test
This commit is contained in:
parent
cfe8fd932f
commit
8e63a0cd76
@ -16,7 +16,8 @@ func clientSendCWMsg(userID64 int64, s string) {
|
||||
|
||||
func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
if _, ok := clientsQueue[m.Msg.UserID64]; ok {
|
||||
if c, ok := clientsCW[m.Msg.UserID64]; ok {
|
||||
if v, ok := clientsCW[m.Msg.UserID64]; ok {
|
||||
c := v.(*ChatWarsClient)
|
||||
if c.LastUpdate.Before(m.Msg.Date) {
|
||||
c.GuildID64 = m.GuildID64
|
||||
c.State = m.State
|
||||
@ -33,7 +34,7 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
State: m.State,
|
||||
LastUpdate: m.Msg.Date,
|
||||
}
|
||||
clientsCW[m.Msg.UserID64] = &c
|
||||
clientsCW.Store(m.Msg.UserID64) = &c
|
||||
if getObjGuildID(``) != m.GuildID64 {
|
||||
clientSendCWMsg(m.Msg.UserID64, "/g_roles")
|
||||
}
|
||||
@ -43,7 +44,8 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
|
||||
|
||||
func clientMsgGRolesAck(m *ChatWarsMessageGRolesAck) {
|
||||
if _, ok := clientsQueue[m.Msg.UserID64]; ok {
|
||||
if c, ok := clientsCW[m.Msg.UserID64]; ok {
|
||||
if v, ok := clientsCW.Load(m.Msg.UserID64); ok {
|
||||
c := v.(*ChatWarsClient)
|
||||
if c.LastUpdate.Before(m.Msg.Date) {
|
||||
if m.CommanderID64 == c.UserID64 {
|
||||
c.Role = `commander`
|
||||
|
5
main.go
5
main.go
@ -62,7 +62,8 @@ var (
|
||||
msgParsingRules map[int]MessageParsingRule
|
||||
clientsKeepAlive map[int64]*MQKeepAlive
|
||||
clientsQueue map[int64]*MQClient
|
||||
clientsCW map[int64]*ChatWarsClient
|
||||
|
||||
clientsCW *sync.Map
|
||||
)
|
||||
|
||||
func PrintText(m *tb.Message) {
|
||||
@ -147,7 +148,7 @@ func main() {
|
||||
JobQueue = make(chan Job, JobQueueSize)
|
||||
clientsQueue = make(map[int64]*MQClient)
|
||||
clientsKeepAlive = make(map[int64]*MQKeepAlive)
|
||||
clientsCW = make(map[int64]*ChatWarsClient)
|
||||
clientsCW = new(sync.Map)
|
||||
|
||||
for w := 1; w <= MQGetMsgWorkers; w++ {
|
||||
go MQGetMsgWorker(w, MQCWMsgQueue)
|
||||
|
Loading…
Reference in New Issue
Block a user