update
This commit is contained in:
parent
26b3368057
commit
be3ec2d355
1
bot.go
1
bot.go
@ -956,6 +956,7 @@ func botGWithdraw(m *tb.Message) {
|
||||
MsgID64: int64(m.ID),
|
||||
ChatID64: m.Chat.ID,
|
||||
Status: 0,
|
||||
Validated: false,
|
||||
}
|
||||
items := []JobPayloadGWithdrawItem{}
|
||||
for _, l := range rx.FindAllStringSubmatch(m.Payload, -1) {
|
||||
|
24
client.go
24
client.go
@ -8,6 +8,30 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func getLockedRoleClient(role string) (*ChirpClient, error) {
|
||||
muxClients.RLock()
|
||||
defer muxClients.RUnlock()
|
||||
|
||||
ids := make([]int64, 0)
|
||||
for _, c := range clients {
|
||||
if c.CWRole == role {
|
||||
ids = append(ids, c.TGUserID64)
|
||||
fmt.Printf("getLockedRoleClient(%s) : appending %s (%d).\n", role, c.Login, c.TGUserID64)
|
||||
}
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil, errors.New("No %s client.", role)
|
||||
}
|
||||
|
||||
RndMux.Lock()
|
||||
id := RndSrc.Intn(len(ids))
|
||||
RndMux.Unlock()
|
||||
|
||||
clients[ids[id]].Mux.Lock()
|
||||
|
||||
return clients[ids[id]], nil
|
||||
}
|
||||
|
||||
func getLockedRandomClient() (*ChirpClient, error) {
|
||||
muxClients.RLock()
|
||||
ids := make([]int64, 0)
|
||||
|
2
def.go
2
def.go
@ -409,6 +409,8 @@ type JobPayloadGWithdraw struct {
|
||||
ChatID64 int64 `json:"chat_id"`
|
||||
Items []JobPayloadGWithdrawItem `json:"items"`
|
||||
Status int64 `json:"status"`
|
||||
CleanupMsg []ChatWarsMessage `json:"cleanup_msg"`
|
||||
Validated bool `json:"validated"`
|
||||
}
|
||||
|
||||
type JobPayloadGDeposit struct {
|
||||
|
2
job.go
2
job.go
@ -1558,6 +1558,8 @@ func jobGWithdraw(j Job) {
|
||||
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
|
||||
clientSendCWMsg(j.UserID64, `/g_stock_other`)
|
||||
} else {
|
||||
c, err := getLockedRoleClient(`Commander`)
|
||||
logOnError(err, "jobGWithdraw: getLockedRoleClient(Commander)")
|
||||
b, _ := json.Marshal(p)
|
||||
log.Printf("jobGWithdraw[%d] : got all the info\n%s\n", j.ID64, string(b))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user