diff --git a/bot/src/config.ts b/bot/src/config.ts index a1bdaf66e..0d898d7d8 100644 --- a/bot/src/config.ts +++ b/bot/src/config.ts @@ -21,6 +21,13 @@ const logger = CreateLayeredLogger(LoggerLayers.botConfigSetup); export interface BotConfig { TACHI_SERVER_LOCATION: string; + // our docker setup is ruined and means we can't pass "bokutachi.xyz" as the + // server location, because docker reads /etc/hosts from another container and + // decides that should resolve to some random internal IP. + // this is stupid. + // i want to remove this hack. + // if you provide this URL, that will be used instead for lookups. + TACHI_SERVER_STUPID_INTERNAL_DOCKER_HACK_LOCATION: string; HTTP_SERVER: { URL: string; }; @@ -50,6 +57,7 @@ function ParseBotConfig(fileLoc = "conf.json5"): BotConfig { const err = p(data, { TACHI_SERVER_LOCATION: "string", + TACHI_SERVER_STUPID_INTERNAL_DOCKER_HACK_LOCATION: "*string", HTTP_SERVER: { URL: "string", }, @@ -87,6 +95,11 @@ function ParseBotConfig(fileLoc = "conf.json5"): BotConfig { throw err; } + // if no stupid hack docker location is set, use tachi_server_location instead. + if (!data.TACHI_SERVER_STUPID_INTERNAL_DOCKER_HACK_LOCATION) { + data.TACHI_SERVER_STUPID_INTERNAL_DOCKER_HACK_LOCATION = data.TACHI_SERVER_LOCATION; + } + return data; } diff --git a/bot/src/utils/fetchTachi.ts b/bot/src/utils/fetchTachi.ts index db7667708..7108ccc9a 100644 --- a/bot/src/utils/fetchTachi.ts +++ b/bot/src/utils/fetchTachi.ts @@ -124,7 +124,7 @@ export function PrependTachiUrl(url: string, version: "1" = "1"): string { url = `/${url}`; } - return `${BotConfig.TACHI_SERVER_LOCATION}/api/v${version}${url}`; + return `${BotConfig.TACHI_SERVER_STUPID_INTERNAL_DOCKER_HACK_LOCATION}/api/v${version}${url}`; } /**