diff --git a/domains/battles/v1/exported.go b/domains/battles/v1/exported.go index 06bbef5..260cd5c 100644 --- a/domains/battles/v1/exported.go +++ b/domains/battles/v1/exported.go @@ -20,8 +20,8 @@ func New(cc *context.Context) { c = cc log = c.Logger.With().Str("domain", "battles").Int("version", 1).Logger() - fightRegex := regexp.MustCompile(`@FWorldBot\s(.*)fight_(.{12})$`) - router.RegisterPrivateRegexp(fightRegex, ForwardCommand) + fightRegexWithoutBot := regexp.MustCompile(`(.*)fight_(.{12})$`) + router.RegisterPrivateRegexp(fightRegexWithoutBot, ForwardCommand) log.Info().Msg("Domain «battles» initialized") } diff --git a/domains/battles/v1/forward.go b/domains/battles/v1/forward.go index ab5f656..01c8657 100644 --- a/domains/battles/v1/forward.go +++ b/domains/battles/v1/forward.go @@ -12,8 +12,13 @@ import ( // ForwardCommand responds to fight request func ForwardCommand(update *telegram.Update) { log.Info().Msg("Battle request received!") + if update.Message.Chat.ID == c.Config.Announces.ChannelID { + log.Info().Msg("This battle is already posted") + } message := update.Message.Text - message = strings.Replace(message, " fight", " join_fight", 1) + if !strings.Contains(message, "join") { + message = strings.Replace(message, "fight", "join_fight", 1) + } message = strings.Replace(message, "@FWorldBot ", "", 1) itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, message)