test get stash
This commit is contained in:
parent
3017ef477b
commit
0314f192ea
25
bot.go
25
bot.go
@ -1074,6 +1074,11 @@ func botCraftAll(m *ChatWarsMessage, r *regexp.Regexp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func botGetStash(m *ChatWarsMessage, r *regexp.Regexp) {
|
func botGetStash(m *ChatWarsMessage, r *regexp.Regexp) {
|
||||||
|
var (
|
||||||
|
userID64 uint64 = 0
|
||||||
|
userBusyUntil time.Time
|
||||||
|
)
|
||||||
|
|
||||||
if hasUnfinishedJob(cacheObjSubType[`job_get_stash`]) {
|
if hasUnfinishedJob(cacheObjSubType[`job_get_stash`]) {
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
Type: commandReplyMsg,
|
Type: commandReplyMsg,
|
||||||
@ -1097,6 +1102,14 @@ func botGetStash(m *ChatWarsMessage, r *regexp.Regexp) {
|
|||||||
if c.Active {
|
if c.Active {
|
||||||
p.ClientCount++
|
p.ClientCount++
|
||||||
p.ClientID64 = append(p.ClientID64, c.TGUserID64)
|
p.ClientID64 = append(p.ClientID64, c.TGUserID64)
|
||||||
|
if userID64 == 0 {
|
||||||
|
userID64 = c.TGUserID64
|
||||||
|
userBusyUntil = c.CWBusyUntil
|
||||||
|
} else if userBusyUntil.After(c.CWBusyUntil) {
|
||||||
|
userID64 = c.TGUserID64
|
||||||
|
userBusyUntil = c.CWBusyUntil
|
||||||
|
}
|
||||||
|
|
||||||
if c.CWBusyUntil.After(busy) {
|
if c.CWBusyUntil.After(busy) {
|
||||||
busy = c.CWBusyUntil
|
busy = c.CWBusyUntil
|
||||||
}
|
}
|
||||||
@ -1104,9 +1117,19 @@ func botGetStash(m *ChatWarsMessage, r *regexp.Regexp) {
|
|||||||
}
|
}
|
||||||
muxClients.RUnlock()
|
muxClients.RUnlock()
|
||||||
|
|
||||||
|
if p.ClientCount == 0 {
|
||||||
|
c := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "No clients online.",
|
||||||
|
FromMsgID64: m.ID64,
|
||||||
|
FromChatID64: m.ChatID64,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- c
|
||||||
|
return
|
||||||
|
}
|
||||||
b, _ := json.Marshal(p)
|
b, _ := json.Marshal(p)
|
||||||
t := time.Now().UTC().Add(1 * time.Second)
|
t := time.Now().UTC().Add(1 * time.Second)
|
||||||
_, err := createJob(cacheObjSubType[`job_get_stash`], objJobPriority, userID64, 0, t, b)
|
_, err = createJob(cacheObjSubType[`job_get_stash`], objJobPriority, userID64, 0, t, b)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
|
Loading…
Reference in New Issue
Block a user