make sure that bot will send all conquers
This commit is contained in:
parent
6b0e4c7a06
commit
ae525cd1e3
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/tribalwarshelp/dcbot/message"
|
"github.com/tribalwarshelp/dcbot/message"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/tribalwarshelp/shared/mode"
|
||||||
shared_models "github.com/tribalwarshelp/shared/models"
|
shared_models "github.com/tribalwarshelp/shared/models"
|
||||||
|
|
||||||
"github.com/tribalwarshelp/dcbot/discord"
|
"github.com/tribalwarshelp/dcbot/discord"
|
||||||
|
@ -52,6 +53,9 @@ func (h *handler) loadEnnoblements(servers []string) map[string]ennoblements {
|
||||||
|
|
||||||
lastEnnoblementAt, ok := h.lastEnnoblementAt[w]
|
lastEnnoblementAt, ok := h.lastEnnoblementAt[w]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
lastEnnoblementAt = time.Now().Add(-1 * time.Minute)
|
||||||
|
}
|
||||||
|
if mode.Get() == mode.DevelopmentMode {
|
||||||
lastEnnoblementAt = time.Now().Add(-60 * time.Minute)
|
lastEnnoblementAt = time.Now().Add(-60 * time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,33 +168,56 @@ func (h *handler) checkEnnoblements() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if group.ConqueredVillagesChannelID != "" && !conqueredVillagesMsg.IsEmpty() {
|
if group.ConqueredVillagesChannelID != "" && !conqueredVillagesMsg.IsEmpty() {
|
||||||
h.discord.SendEmbed(group.ConqueredVillagesChannelID,
|
fields := conqueredVillagesMsg.ToMessageEmbedFields()
|
||||||
discord.
|
title := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||||
NewEmbed().
|
MessageID: "cron.conqueredVillages.title",
|
||||||
SetTitle(localizer.MustLocalize(&i18n.LocalizeConfig{
|
DefaultMessage: message.FallbackMsg("cron.conqueredVillages.title",
|
||||||
MessageID: "cron.conqueredVillages.title",
|
"Conquered villages"),
|
||||||
DefaultMessage: message.FallbackMsg("cron.conqueredVillages.title",
|
})
|
||||||
"Conquered villages"),
|
timestamp := formatDateOfConquest(time.Now())
|
||||||
})).
|
|
||||||
SetColor(colorConqueredVillage).
|
for i := 0; i < len(fields); i += discord.EmbedLimitField {
|
||||||
SetFields(conqueredVillagesMsg.ToMessageEmbedFields()).
|
end := i + discord.EmbedLimitField
|
||||||
SetTimestamp(formatDateOfConquest(time.Now())).
|
|
||||||
MessageEmbed)
|
if end > len(fields) {
|
||||||
|
end = len(fields)
|
||||||
|
}
|
||||||
|
|
||||||
|
h.discord.SendEmbed(group.ConqueredVillagesChannelID,
|
||||||
|
discord.
|
||||||
|
NewEmbed().
|
||||||
|
SetTitle(title).
|
||||||
|
SetColor(colorConqueredVillage).
|
||||||
|
SetFields(fields[i:end]).
|
||||||
|
SetTimestamp(timestamp).
|
||||||
|
MessageEmbed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if group.LostVillagesChannelID != "" && !lostVillagesMsg.IsEmpty() {
|
if group.LostVillagesChannelID != "" && !lostVillagesMsg.IsEmpty() {
|
||||||
h.discord.SendEmbed(group.LostVillagesChannelID,
|
fields := lostVillagesMsg.ToMessageEmbedFields()
|
||||||
discord.
|
title := localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||||
NewEmbed().
|
MessageID: "cron.lostVillages.title",
|
||||||
SetTitle(localizer.MustLocalize(&i18n.LocalizeConfig{
|
DefaultMessage: message.FallbackMsg("cron.lostVillages.title",
|
||||||
MessageID: "cron.lostVillages.title",
|
"Lost villages"),
|
||||||
DefaultMessage: message.FallbackMsg("cron.lostVillages.title",
|
})
|
||||||
"Lost villages"),
|
timestamp := formatDateOfConquest(time.Now())
|
||||||
})).
|
for i := 0; i < len(fields); i += discord.EmbedLimitField {
|
||||||
SetColor(colorLostVillage).
|
end := i + discord.EmbedLimitField
|
||||||
SetFields(lostVillagesMsg.ToMessageEmbedFields()).
|
|
||||||
SetTimestamp(formatDateOfConquest(time.Now())).
|
if end > len(fields) {
|
||||||
MessageEmbed)
|
end = len(fields)
|
||||||
|
}
|
||||||
|
|
||||||
|
h.discord.SendEmbed(group.LostVillagesChannelID,
|
||||||
|
discord.
|
||||||
|
NewEmbed().
|
||||||
|
SetTitle(title).
|
||||||
|
SetColor(colorLostVillage).
|
||||||
|
SetFields(fields[i:end]).
|
||||||
|
SetTimestamp(timestamp).
|
||||||
|
MessageEmbed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -11,7 +11,7 @@ require (
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/segmentio/encoding v0.1.14 // indirect
|
github.com/segmentio/encoding v0.1.14 // indirect
|
||||||
github.com/tribalwarshelp/golang-sdk v0.0.0-20200721095058-9ee3513a54a9
|
github.com/tribalwarshelp/golang-sdk v0.0.0-20200721095058-9ee3513a54a9
|
||||||
github.com/tribalwarshelp/shared v0.0.0-20200721094728-9ea33a732990
|
github.com/tribalwarshelp/shared v0.0.0-20200721124533-776cbb36074b
|
||||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
|
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
|
||||||
golang.org/x/text v0.3.2
|
golang.org/x/text v0.3.2
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -109,6 +109,8 @@ github.com/tribalwarshelp/golang-sdk v0.0.0-20200721095058-9ee3513a54a9 h1:y4fY0
|
||||||
github.com/tribalwarshelp/golang-sdk v0.0.0-20200721095058-9ee3513a54a9/go.mod h1:wRoVfjxu4FozpiJmDknv5Zw4AOx/0IC+VttDaSTpBg8=
|
github.com/tribalwarshelp/golang-sdk v0.0.0-20200721095058-9ee3513a54a9/go.mod h1:wRoVfjxu4FozpiJmDknv5Zw4AOx/0IC+VttDaSTpBg8=
|
||||||
github.com/tribalwarshelp/shared v0.0.0-20200721094728-9ea33a732990 h1:PwMCKm5Wvqq+tP3KvdqxPtxKtKZTaEONCBT5DvpbVrc=
|
github.com/tribalwarshelp/shared v0.0.0-20200721094728-9ea33a732990 h1:PwMCKm5Wvqq+tP3KvdqxPtxKtKZTaEONCBT5DvpbVrc=
|
||||||
github.com/tribalwarshelp/shared v0.0.0-20200721094728-9ea33a732990/go.mod h1:tf+2yTHasV6jAF3V2deZ9slNoCyBzC0fMdTjI7clf6Y=
|
github.com/tribalwarshelp/shared v0.0.0-20200721094728-9ea33a732990/go.mod h1:tf+2yTHasV6jAF3V2deZ9slNoCyBzC0fMdTjI7clf6Y=
|
||||||
|
github.com/tribalwarshelp/shared v0.0.0-20200721124533-776cbb36074b h1:8bgZG6Zi3ROqtvpeUOj3a19mtES88VjeNwkUF0FI+Vs=
|
||||||
|
github.com/tribalwarshelp/shared v0.0.0-20200721124533-776cbb36074b/go.mod h1:tf+2yTHasV6jAF3V2deZ9slNoCyBzC0fMdTjI7clf6Y=
|
||||||
github.com/vmihailenco/bufpool v0.1.5/go.mod h1:fL9i/PRTuS7AELqAHwSU1Zf1c70xhkhGe/cD5ud9pJk=
|
github.com/vmihailenco/bufpool v0.1.5/go.mod h1:fL9i/PRTuS7AELqAHwSU1Zf1c70xhkhGe/cD5ud9pJk=
|
||||||
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
||||||
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
||||||
|
|
Reference in New Issue