Skip to content

Commit

Permalink
fix: target name for Discord/Telegram bots (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Jan 9, 2025
1 parent 6415aa3 commit 00fb22c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
3 changes: 1 addition & 2 deletions config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const (
)

const (
BotNamePaguMainnet = "Pagu-Mainnet"
BotNamePaguStaging = "Pagu-Staging"
BotNamePaguMainnet = "Pagu"
BotNamePaguTestnet = "Pagu-Testnet"
BotNamePaguModerator = "Pagu-Moderator"
)
13 changes: 11 additions & 2 deletions internal/platforms/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ func (bot *Bot) registerCommands() error {
}

switch bot.target {
case config.BotNamePaguMainnet,
config.BotNamePaguStaging:
case config.BotNamePaguMainnet:
if !utils.IsFlagSet(cmd.TargetFlag, command.TargetMaskMainnet) {
continue
}
Expand All @@ -103,6 +102,11 @@ func (bot *Bot) registerCommands() error {
if !utils.IsFlagSet(cmd.TargetFlag, command.TargetMaskModerator) {
continue
}

default:
log.Warn("invalid target", "target", bot.target)

continue
}

log.Info("registering new command", "name", cmd.Name, "desc", cmd.Help, "index", i, "object", cmd)
Expand Down Expand Up @@ -130,6 +134,11 @@ func (bot *Bot) registerCommands() error {
if !utils.IsFlagSet(subCmd.TargetFlag, command.TargetMaskModerator) {
continue
}

default:
log.Warn("invalid target", "target", bot.target)

continue
}

log.Info("adding sub-command", "command", cmd.Name,
Expand Down
15 changes: 15 additions & 0 deletions internal/platforms/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ func (bot *Bot) registerCommands() error {
if !utils.IsFlagSet(beCmd.TargetFlag, command.TargetMaskTestnet) {
continue
}

case config.BotNamePaguModerator:
if !utils.IsFlagSet(beCmd.TargetFlag, command.TargetMaskModerator) {
continue
}

default:
log.Warn("invalid target", "target", bot.target)

continue
}

log.Info("registering new command", "name", beCmd.Name, "desc", beCmd.Help, "index", i, "object", beCmd)
Expand All @@ -135,6 +145,11 @@ func (bot *Bot) registerCommands() error {
if !utils.IsFlagSet(sCmd.TargetFlag, command.TargetMaskModerator) {
continue
}

default:
log.Warn("invalid target", "target", bot.target)

continue
}

log.Info("adding command sub-command", "command", beCmd.Name,
Expand Down

0 comments on commit 00fb22c

Please sign in to comment.