Skip to content

Commit

Permalink
Created mock TwitchBot for local builds
Browse files Browse the repository at this point in the history
  • Loading branch information
DevinLeamy committed Sep 1, 2023
1 parent 0f2f417 commit 2093ceb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/shared/twitch/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export interface TwitchBot {
getChannel: (channel: string) => Promise<TwitchChannel | undefined>;
}

export class DisabledTwitchBot implements TwitchBot {
async getChannel(_channel: string): Promise<TwitchChannel | undefined> {
return undefined;
}
}

export class TwitchBotImpl implements TwitchBot {
private accessToken: string | undefined;
private expiresAt: number | undefined;
Expand Down Expand Up @@ -99,6 +105,9 @@ export class TwitchBotImpl implements TwitchBot {
export async function registerTwitchBot<C>(
_loader: RegistryLoader<C>
): Promise<TwitchBot> {
if (process.env.NOVE_ENV !== "production" && !process.env.ALLOW_DEV_TWITCH) {
return new DisabledTwitchBot();
}
const bot = new TwitchBotImpl();
await bot.login();
return bot;
Expand Down

0 comments on commit 2093ceb

Please sign in to comment.