test set busy

This commit is contained in:
shoopea 2020-01-16 14:17:33 +08:00
parent d02d14a27b
commit d49088de3b
2 changed files with 5 additions and 1 deletions

View File

@ -56,12 +56,15 @@ func getLockedRandomClient() (*ChirpClient, error) {
func setClientBusy(userID64 int64, from time.Time, duration time.Duration) error { func setClientBusy(userID64 int64, from time.Time, duration time.Duration) error {
if clt, ok := getLockedClient(userID64, false); ok { if clt, ok := getLockedClient(userID64, false); ok {
t := time.Now().UTC()
log.Printf("setClientBusy[%s] : now %s.\n", clt.Login, t.Format(timeFmt))
log.Printf("setClientBusy[%s] : until %s.\n", clt.Login, from.UTC().Add(duration).Format(timeFmt))
if from.UTC().Add(duration).After(time.Now().UTC()) { if from.UTC().Add(duration).After(time.Now().UTC()) {
clt.CWIdle = false clt.CWIdle = false
clt.CWBusyUntil = from.UTC().Add(duration) clt.CWBusyUntil = from.UTC().Add(duration)
log.Printf("setClientBusy[%s] : set for %s.\n", clt.Login, duration.String()) log.Printf("setClientBusy[%s] : set for %s.\n", clt.Login, duration.String())
} else { } else {
log.Printf("setClientBusy[%s] : not updated.\n", clt.Login) log.Printf("setClientBusy[%s] : not updated (.\n", clt.Login)
} }
clt.Mux.Unlock() clt.Mux.Unlock()
return nil return nil

1
def.go
View File

@ -12,6 +12,7 @@ import (
const maxUnixTimestamp int64 = 2147483647 const maxUnixTimestamp int64 = 2147483647
const chtwrsbotID64 int64 = 408101137 const chtwrsbotID64 int64 = 408101137
const angrybirbsbotID64 int64 = 833409972 const angrybirbsbotID64 int64 = 833409972
const timeFmt string = "2006-01-02T15:04:05+07:00"
type Config struct { type Config struct {
Telegram struct { Telegram struct {