setup for auto def

This commit is contained in:
shoopea 2020-04-07 10:14:20 +08:00
parent d8ccfda9e3
commit 402e5047fa
4 changed files with 17 additions and 1 deletions

5
bot.go
View File

@ -923,6 +923,11 @@ func botUserConfig(m *ChatWarsMessage) {
} else { } else {
out = fmt.Sprintf("%s Pillage : OFF (<a href=\"https://t.me/share/url?url=/config_pillage_on\">set on</a>)\n", out) out = fmt.Sprintf("%s Pillage : OFF (<a href=\"https://t.me/share/url?url=/config_pillage_on\">set on</a>)\n", out)
} }
if clt.Config.Wartime == `🛡Defend` {
out = fmt.Sprintf("%s Wartime : DEFEND CASTLE (<a href=\"https://t.me/share/url?url=/config_def_guild\">set to guild</a>)\n", out)
} else {
out = fmt.Sprintf("%s Wartime : DEFEND GUILD (<a href=\"https://t.me/share/url?url=/config_def_castle\">set to castle</a>)\n", out)
}
c := TGCommand{ c := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,
Text: out, Text: out,

View File

@ -35,6 +35,14 @@ func loadClients() error {
if cx.Config == nil { if cx.Config == nil {
cx.Config = &ChirpConfig{ cx.Config = &ChirpConfig{
InterceptPillage: true, InterceptPillage: true,
Wartime: `🛡Defend`,
}
} else {
if cx.Config.InterceptPillage == nil {
cx.Config.InterceptPillage = true
}
if cx.Config.Wartime == nil {
cx.Config.Wartime = `🛡Defend`
} }
} }
/* /*

1
def.go
View File

@ -103,6 +103,7 @@ type ChirpConfig struct {
AutoDeposit bool `json:"auto_deposit"` AutoDeposit bool `json:"auto_deposit"`
AutoDepositItems []string `json:"auto_deposit_items"` AutoDepositItems []string `json:"auto_deposit_items"`
AutoDepositTypes []string `json:"auto_deposit_types"` AutoDepositTypes []string `json:"auto_deposit_types"`
Wartime string `json:"wartime"`
} }
type ChirpClient struct { type ChirpClient struct {

4
job.go
View File

@ -1868,7 +1868,9 @@ func jobSetDef(j Job) {
cwm, err := parseSubTypeMessageMeAck(msg, rule.re) cwm, err := parseSubTypeMessageMeAck(msg, rule.re)
if cwm.State == `🛌Rest` { 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) err = setJobDone(j.ID64)