client revamp compilation fix

This commit is contained in:
shoopea 2019-07-31 14:24:52 +08:00
parent e775d55e2e
commit e56a19b494
2 changed files with 12 additions and 11 deletions

3
bot.go
View File

@ -139,7 +139,8 @@ func botTest(m *tb.Message) {
if !m.Private() { if !m.Private() {
return return
} }
if _, ok := clientsKeepAlive.Load(m.Chat.ID); ok { if clt, ok := getLockedClient(m.Chat.ID, false); ok {
clt.Mux.Unlock()
clientSendCWMsg(m.Chat.ID, "🏅Me") clientSendCWMsg(m.Chat.ID, "🏅Me")
c := TGCommand{ c := TGCommand{

View File

@ -23,7 +23,7 @@ func getLockedClient(id int64, createMissing bool) (*ChirpClient, bool) {
return c, true return c, true
} else { } else {
muxClients.RUnlock() muxClients.RUnlock()
return 0, false return nil, false
} }
} }
@ -60,7 +60,7 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
} }
} }
} }
clt.Unlock() clt.Mux.Unlock()
} }
} }
@ -72,7 +72,7 @@ func clientMsgGoQuestAck(m *ChatWarsMessageGoQuestAck) {
clt.CWBusyUntil = m.Msg.Date.Add(m.Duration) clt.CWBusyUntil = m.Msg.Date.Add(m.Duration)
} }
} }
clt.Unlock() clt.Mux.Unlock()
} }
} }
@ -81,27 +81,27 @@ func clientMsgGRolesAck(m *ChatWarsMessageGRolesAck) {
if clt.Active { if clt.Active {
if clt.CWLastUpdate.Before(m.Msg.Date) { if clt.CWLastUpdate.Before(m.Msg.Date) {
if m.CommanderID64 == clt.CWUserID64 { if m.CommanderID64 == clt.CWUserID64 {
c.Role = `commander` clt.CWRole = `commander`
} else if m.BartenderID64 == clt.CWUserID64 { } else if m.BartenderID64 == clt.CWUserID64 {
c.Role = `bartender` clt.CWRole = `bartender`
} else if m.SquireID64 == clt.CWUserID64 { } else if m.SquireID64 == clt.CWUserID64 {
c.Role = `squire` clt.CWRole = `squire`
} else if m.TreasurerID64 == clt.CWUserID64 { } else if m.TreasurerID64 == clt.CWUserID64 {
c.Role = `treasurer` clt.CWRole = `treasurer`
} else { } else {
c.Role = `none` clt.CWRole = `none`
} }
clt.CWLastUpdate = m.Msg.Date clt.CWLastUpdate = m.Msg.Date
} }
} }
clt.Unlock() clt.Mux.Unlock()
} }
} }
func clientGetCWUserID64(tgUserID64 int64) (int64, error) { func clientGetCWUserID64(tgUserID64 int64) (int64, error) {
if clt, ok := getLockedClient(m.Msg.UserID64, false); ok { if clt, ok := getLockedClient(m.Msg.UserID64, false); ok {
i := clt.CWUserID64 i := clt.CWUserID64
clt.Unlock() clt.Mux.Unlock()
return i, nil return i, nil
} }
return 0, errors.New("Unknown user_id.") return 0, errors.New("Unknown user_id.")