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