From 402e5047fa4df0f263e510ef208683f705d1d3ca Mon Sep 17 00:00:00 2001 From: shoopea Date: Tue, 7 Apr 2020 10:14:20 +0800 Subject: [PATCH] setup for auto def --- bot.go | 5 +++++ client.go | 8 ++++++++ def.go | 1 + job.go | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index 9fd5470..6483118 100644 --- a/bot.go +++ b/bot.go @@ -923,6 +923,11 @@ func botUserConfig(m *ChatWarsMessage) { } else { out = fmt.Sprintf("%s Pillage : OFF (set on)\n", out) } + if clt.Config.Wartime == `🛡Defend` { + out = fmt.Sprintf("%s Wartime : DEFEND CASTLE (set to guild)\n", out) + } else { + out = fmt.Sprintf("%s Wartime : DEFEND GUILD (set to castle)\n", out) + } c := TGCommand{ Type: commandReplyMsg, Text: out, diff --git a/client.go b/client.go index 86d2d6c..41a9839 100644 --- a/client.go +++ b/client.go @@ -35,6 +35,14 @@ func loadClients() error { if cx.Config == nil { cx.Config = &ChirpConfig{ InterceptPillage: true, + Wartime: `🛡Defend`, + } + } else { + if cx.Config.InterceptPillage == nil { + cx.Config.InterceptPillage = true + } + if cx.Config.Wartime == nil { + cx.Config.Wartime = `🛡Defend` } } /* diff --git a/def.go b/def.go index de1c1c2..bd5778c 100644 --- a/def.go +++ b/def.go @@ -103,6 +103,7 @@ type ChirpConfig struct { AutoDeposit bool `json:"auto_deposit"` AutoDepositItems []string `json:"auto_deposit_items"` AutoDepositTypes []string `json:"auto_deposit_types"` + Wartime string `json:"wartime"` } type ChirpClient struct { diff --git a/job.go b/job.go index 0a32dc1..257e6f9 100644 --- a/job.go +++ b/job.go @@ -1868,7 +1868,9 @@ func jobSetDef(j Job) { cwm, err := parseSubTypeMessageMeAck(msg, rule.re) if cwm.State == `🛌Rest` { - clientSendCWMsg(j.UserID64, `🛡Defend`) + clt, err := getLockedClient(j.UserID64, false) + clt.Mux.Unlock() + clientSendCWMsg(j.UserID64, clt.Config.Wartime) } err = setJobDone(j.ID64)