Skip to content

Commit

Permalink
HIERARCHICAL TOPICS MEANS NO MORE METADATA
Browse files Browse the repository at this point in the history
  • Loading branch information
bbriggs committed Jan 23, 2024
1 parent d4bad57 commit 4d02ae8
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 1,019 deletions.
140 changes: 0 additions & 140 deletions examples/pingpong/main.go

This file was deleted.

86 changes: 0 additions & 86 deletions examples/py-pingpong/pingpong.py

This file was deleted.

6 changes: 0 additions & 6 deletions examples/py-pingpong/requirements.txt

This file was deleted.

31 changes: 31 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# fly.toml app configuration file generated for bytebot-discord-gateway on 2023-12-08T05:05:12Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "bytebot-discord-gateway"
primary_region = "atl"
kill_signal = "SIGINT"
kill_timeout = "5s"

[build]
dockerfile = "Dockerfile"

[env]
# Pattern is <protocol>.<server>.<env>
BYTEBOT_ID = "discord.sithmail.prod"
# Pattern is <direction>.<protocol>.<server>.<env>
BYTEBOT_INBOUND = "inbound.discord.sithmail.prod"
# Pattern is <direction>.<protocol>.<server>.<env>
BYTEBOT_OUTBOUND = "outbound.discord.sithmail.prod"
REDIS_URL = "fly-bytebot.upstash.io:6379"
BYTEBOT_LOG_LEVEL = "DEBUG"

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024

[[metrics]]
port = 8080
path = "/metrics"
8 changes: 0 additions & 8 deletions heroku.yml

This file was deleted.

16 changes: 13 additions & 3 deletions messageCreateHandler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"encoding/json"

"github.com/bwmarrin/discordgo"
"github.com/rs/zerolog/log"
)
Expand All @@ -22,11 +24,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
}

// Topic ID is derived from the protocol, server, channel, and user and dot-delimited
// Example for sithmail: discord.sithmail.#channel.user
topic := "discord." + m.GuildID + "." + m.ChannelID + "." + m.Author.ID
// Example for sithmail: inbound.discord.sithmail.#channel.user
topic := "inbound.discord." + m.GuildID + "." + m.ChannelID + "." + m.Author.ID

// Marshal the message into a byte array
// This is required because Redis only accepts byte arrays
jsonBytes, err := json.Marshal(m)
if err != nil {
log.Err(err).Msg("Failed to marshal message into JSON")
return
}

// Publish the message to redis
res := rdb.Publish(redisCtx, topic, m)
res := rdb.Publish(redisCtx, topic, jsonBytes)
if res.Err() != nil {
log.Err(res.Err()).Msg("Unable to publish message")
return
Expand Down
Loading

0 comments on commit 4d02ae8

Please sign in to comment.