Skip to content

Commit

Permalink
feat: ignored channels
Browse files Browse the repository at this point in the history
  • Loading branch information
invakid404 committed Jun 27, 2022
1 parent dead37d commit deadcce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Binary file modified .env.secret
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitsecret/paths/mapping.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.env:79e04f96dace0655cc4b5523605d674c6fdd7d3dfe2c03d0bbe4395cd0b3e11e
.env:11f3566b8b91b77b9fcce7f3544ad001ea7d9254b179d9ba7cc5719b5cc43cc6
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func main() {
log.Fatalln("`KEK_EMOJI` env variable is not set")
}

ignoredChannels := make(map[string]struct{})
for _, ignoredChannel := range strings.Split(os.Getenv("IGNORED_CHANNELS"), ",") {
ignoredChannels[ignoredChannel] = struct{}{}
}

client, err := discordgo.New("Bot " + token)
if err != nil {
log.Fatalln("failed to create discord client:", err)
Expand Down Expand Up @@ -212,6 +217,10 @@ func main() {

go func() {
reactionHandler := func(ctx reactionContext) {
if _, ok := ignoredChannels[ctx.Reaction.ChannelID]; ok {
return
}

message, err := getMessage(ctx.Session, ctx.Reaction.ChannelID, ctx.Reaction.MessageID)
if err != nil {
log.Println("received reaction but unable to get message:", ctx.Reaction.ChannelID, ctx.Reaction.MessageID)
Expand Down
2 changes: 2 additions & 0 deletions manifests/kekboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ spec:
value: "963154894989197392"
- name: KEK_EMOJI
value: "<:kek:804343486924849162>"
- name: IGNORED_CHANNELS
value: "825440092533293066"
ports:
- containerPort: 8080
volumeMounts:
Expand Down

0 comments on commit deadcce

Please sign in to comment.