mirror of
https://gitlab.com/qwerinope/qweribot.git
synced 2026-02-04 09:46:57 +01:00
small refactor and small lootbox rebalance SMILERS
This commit is contained in:
34
src/index.ts
34
src/index.ts
@@ -1,25 +1,17 @@
|
||||
import { createAuthProvider } from "./auth";
|
||||
import { chatterId, streamerId, singleUserMode, streamerUsers } from "main";
|
||||
import { ApiClient } from "@twurple/api";
|
||||
import { EventSubWsListener } from "@twurple/eventsub-ws";
|
||||
import { addAdmin } from "lib/admins";
|
||||
import logger from "lib/logger";
|
||||
import { addInvuln } from "lib/invuln";
|
||||
import { redis } from "bun";
|
||||
import { remodMod, timeoutDuration } from "lib/timeout";
|
||||
import User from "user";
|
||||
import { connectionCheck } from "connectionCheck";
|
||||
import logger from "lib/logger";
|
||||
import { redis } from "lib/redis";
|
||||
import { createAuthProvider } from "auth";
|
||||
import { EventSubWsListener } from "@twurple/eventsub-ws";
|
||||
import { user, password, database, host } from "db/connection";
|
||||
|
||||
await connectionCheck();
|
||||
|
||||
const CHATTERINTENTS = ["user:read:chat", "user:write:chat", "user:bot", "user:manage:whispers"];
|
||||
const STREAMERINTENTS = ["channel:bot", "user:read:chat", "moderation:read", "channel:manage:moderators", "moderator:manage:chat_messages", "moderator:manage:banned_users", "bits:read", "channel:moderate", "moderator:manage:shoutouts", "channel:read:subscriptions", "channel:manage:redemptions"];
|
||||
|
||||
export const singleUserMode = process.env.CHATTER_IS_STREAMER === 'true';
|
||||
export const chatterId = process.env.CHATTER_ID ?? "";
|
||||
if (chatterId === "") { logger.enverr('CHATTER_ID'); process.exit(1); };
|
||||
export const streamerId = process.env.STREAMER_ID ?? "";
|
||||
if (streamerId === "") { logger.enverr('STREAMER_ID'); process.exit(1); };
|
||||
|
||||
export const chatterAuthProvider = await createAuthProvider(chatterId, singleUserMode ? CHATTERINTENTS.concat(STREAMERINTENTS) : CHATTERINTENTS);
|
||||
export const streamerAuthProvider = singleUserMode ? undefined : await createAuthProvider(streamerId, STREAMERINTENTS, true);
|
||||
|
||||
@@ -34,11 +26,20 @@ export const eventSub = new EventSubWsListener({ apiClient: streamerApi });
|
||||
|
||||
export const chatterEventSub = singleUserMode ? eventSub : new EventSubWsListener({ apiClient: chatterApi });
|
||||
|
||||
export const commandPrefix = process.env.COMMAND_PREFIX ?? "!";
|
||||
if (chatterId === "") { logger.enverr('CHATTER_ID'); process.exit(1); };
|
||||
if (streamerId === "") { logger.enverr('STREAMER_ID'); process.exit(1); };
|
||||
if (!user) { logger.enverr("POSTGRES_USER"); process.exit(1); };
|
||||
if (!password) { logger.enverr("POSTGRES_USER"); process.exit(1); };
|
||||
if (!database) { logger.enverr("POSTGRES_DB"); process.exit(1); };
|
||||
if (!host) { logger.enverr("POSTGRES_HOST"); process.exit(1); };
|
||||
|
||||
if (!singleUserMode) await redis.set(`user:${chatterId}:bot`, '1');
|
||||
|
||||
export const streamerUsers = [chatterId, streamerId];
|
||||
import { addAdmin } from "lib/admins";
|
||||
import { addInvuln } from "lib/invuln";
|
||||
import User from "user";
|
||||
import { remodMod, timeoutDuration } from "lib/timeout";
|
||||
|
||||
streamerUsers.forEach(async id => await Promise.all([addAdmin(id), addInvuln(id), redis.set(`user:${id}:mod`, '1')]));
|
||||
|
||||
const banned = await streamerApi.moderation.getBannedUsers(streamerId).then(a => a.data);
|
||||
@@ -88,3 +89,4 @@ await import("./events");
|
||||
await import("./pointRedeems");
|
||||
|
||||
await import("./web");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user