Add small fix for battle regex and forward
This commit is contained in:
parent
0ba20b3ed5
commit
593e02b10b
@ -20,8 +20,8 @@ func New(cc *context.Context) {
|
|||||||
c = cc
|
c = cc
|
||||||
log = c.Logger.With().Str("domain", "battles").Int("version", 1).Logger()
|
log = c.Logger.With().Str("domain", "battles").Int("version", 1).Logger()
|
||||||
|
|
||||||
fightRegex := regexp.MustCompile(`@FWorldBot\s(.*)fight_(.{12})$`)
|
fightRegexWithoutBot := regexp.MustCompile(`(.*)fight_(.{12})$`)
|
||||||
router.RegisterPrivateRegexp(fightRegex, ForwardCommand)
|
router.RegisterPrivateRegexp(fightRegexWithoutBot, ForwardCommand)
|
||||||
|
|
||||||
log.Info().Msg("Domain «battles» initialized")
|
log.Info().Msg("Domain «battles» initialized")
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,13 @@ import (
|
|||||||
// ForwardCommand responds to fight request
|
// ForwardCommand responds to fight request
|
||||||
func ForwardCommand(update *telegram.Update) {
|
func ForwardCommand(update *telegram.Update) {
|
||||||
log.Info().Msg("Battle request received!")
|
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 := 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)
|
message = strings.Replace(message, "@FWorldBot ", "", 1)
|
||||||
|
|
||||||
itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, message)
|
itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, message)
|
||||||
|
Reference in New Issue
Block a user