Add battle announces to channel
Channel ID is configured in fw_zookeeper.yaml.
This commit is contained in:
27
domains/battles/v1/exported.go
Normal file
27
domains/battles/v1/exported.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Fantasy World Zookeeper Bot
|
||||
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package battlesv1
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
"lab.wtfteam.pro/fat0troll/fw_zookeeper/context"
|
||||
"lab.wtfteam.pro/fat0troll/fw_zookeeper/internal/router"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
c *context.Context
|
||||
log zerolog.Logger
|
||||
)
|
||||
|
||||
// New initializes package
|
||||
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)
|
||||
|
||||
log.Info().Msg("Domain «battles» initialized")
|
||||
}
|
20
domains/battles/v1/forward.go
Normal file
20
domains/battles/v1/forward.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Fantasy World Zookeeper Bot
|
||||
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package battlesv1
|
||||
|
||||
import (
|
||||
"gitlab.com/toby3d/telegram"
|
||||
itelegram "lab.wtfteam.pro/fat0troll/fw_zookeeper/internal/telegram"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ForwardCommand responds to fight request
|
||||
func ForwardCommand(update *telegram.Update) {
|
||||
log.Info().Msg("Battle request received!")
|
||||
message := update.Message.Text
|
||||
message = strings.Replace(message, " fight", " join_fight", 1)
|
||||
message = strings.Replace(message, "@FWorldBot ", "", 1)
|
||||
|
||||
itelegram.RespondWithoutMarkdown(c.Config.Announces.ChannelID, message)
|
||||
}
|
Reference in New Issue
Block a user