Skip to content

Commit 8a9df0d

Browse files
committed
Add ADMIN_IDS configuration for self-bot administrator management
1 parent c97db69 commit 8a9df0d

5 files changed

Lines changed: 87 additions & 67 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PREFIX = "$" # The prefix used to trigger your self-bot commands
44
GUILD_ID = "" # The ID of the Discord server your self-bot will be running on
55
COMMAND_CHANNEL_ID = "" # The ID of the Discord channel where your self-bot will respond to commands
66
VIDEO_CHANNEL_ID = "" # The ID of the Discord voice/video channel where your self-bot will stream videos
7+
ADMIN_IDS = ["YOUR_USER_ID_HERE"] # A list of Discord user IDs that are considered administrators (comma-separated or JSON array format)
78

89
# General options
910
VIDEOS_DIR = "./videos" # The local path where you store video files

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ PREFIX = "$" # The prefix used to trigger your self-bot commands
136136
GUILD_ID = "" # The ID of the Discord server your self-bot will be running on
137137
COMMAND_CHANNEL_ID = "" # The ID of the Discord channel where your self-bot will respond to commands
138138
VIDEO_CHANNEL_ID = "" # The ID of the Discord voice/video channel where your self-bot will stream videos
139+
ADMIN_IDS = ["YOUR_USER_ID_HERE"] # A list of Discord user IDs that are considered administrators (comma-separated or JSON array format)
139140

140141
# General options
141142
VIDEOS_DIR = "./videos" # The local path where you store video files

docker-compose-warp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
GUILD_ID: "" # The ID of the Discord server your self-bot will be running on
1111
COMMAND_CHANNEL_ID: "" # The ID of the Discord channel where your self-bot will respond to commands
1212
VIDEO_CHANNEL_ID: "" # The ID of the Discord voice/video channel where your self-bot will stream videos
13-
13+
ADMIN_IDS: ["YOUR_USER_ID_HERE"] # A list of Discord user IDs that are considered administrators (comma-separated or JSON array format)
1414
# General options
1515
VIDEOS_DIR: "./videos" # The local path where you store video files
1616
PREVIEW_CACHE_DIR: "./tmp/preview-cache" # The local path where your self-bot will cache video preview thumbnails
@@ -32,7 +32,7 @@ services:
3232
# H26x; otherwise, it should be disabled or ignored.
3333
# Available presets: "ultrafast", "superfast", "veryfast", "faster",
3434
# "fast", "medium", "slow", "slower", "veryslow".
35-
STREAM_H26X_PRESET: "veryfast"
35+
STREAM_H26X_PRESET: "ultrafast"
3636

3737
# Videos server options
3838
SERVER_ENABLED: "false" # Whether to enable the built-in video server

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
GUILD_ID: "" # The ID of the Discord server your self-bot will be running on
1111
COMMAND_CHANNEL_ID: "" # The ID of the Discord channel where your self-bot will respond to commands
1212
VIDEO_CHANNEL_ID: "" # The ID of the Discord voice/video channel where your self-bot will stream videos
13-
13+
ADMIN_IDS: ["YOUR_USER_ID_HERE"] # A list of Discord user IDs that are considered administrators (comma-separated or JSON array format)
1414
# General options
1515
VIDEOS_DIR: "./videos" # The local path where you store video files
1616
PREVIEW_CACHE_DIR: "./tmp/preview-cache" # The local path where your self-bot will cache video preview thumbnails

src/config.ts

Lines changed: 82 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,96 @@
11
import dotenv from "dotenv"
22
import bcrypt from "bcrypt";
33

4-
dotenv.config({quiet: true});
4+
dotenv.config({ quiet: true });
55

66
const VALID_VIDEO_CODECS = ['VP8', 'H264', 'H265', 'VP9', 'AV1'];
77

8-
export default {
9-
// Selfbot options
10-
token: process.env.TOKEN || '',
11-
prefix: process.env.PREFIX || '',
12-
guildId: process.env.GUILD_ID ? process.env.GUILD_ID : '',
13-
cmdChannelId: process.env.COMMAND_CHANNEL_ID ? process.env.COMMAND_CHANNEL_ID : '',
14-
videoChannelId: process.env.VIDEO_CHANNEL_ID ? process.env.VIDEO_CHANNEL_ID : '',
15-
16-
// General options
17-
videosDir: process.env.VIDEOS_DIR ? process.env.VIDEOS_DIR : './videos',
18-
previewCacheDir: process.env.PREVIEW_CACHE_DIR ? process.env.PREVIEW_CACHE_DIR : './tmp/preview-cache',
19-
20-
// Stream options
21-
respect_video_params: process.env.STREAM_RESPECT_VIDEO_PARAMS ? parseBoolean(process.env.STREAM_RESPECT_VIDEO_PARAMS) : false,
22-
width: process.env.STREAM_WIDTH ? parseInt(process.env.STREAM_WIDTH) : 1280,
23-
height: process.env.STREAM_HEIGHT ? parseInt(process.env.STREAM_HEIGHT) : 720,
24-
fps: process.env.STREAM_FPS ? parseInt(process.env.STREAM_FPS) : 30,
25-
bitrateKbps: process.env.STREAM_BITRATE_KBPS ? parseInt(process.env.STREAM_BITRATE_KBPS) : 1000,
26-
maxBitrateKbps: process.env.STREAM_MAX_BITRATE_KBPS ? parseInt(process.env.STREAM_MAX_BITRATE_KBPS) : 2500,
27-
hardwareAcceleratedDecoding: process.env.STREAM_HARDWARE_ACCELERATION ? parseBoolean(process.env.STREAM_HARDWARE_ACCELERATION) : false,
28-
h26xPreset: process.env.STREAM_H26X_PRESET ? parsePreset(process.env.STREAM_H26X_PRESET) : 'ultrafast',
29-
videoCodec: process.env.STREAM_VIDEO_CODEC ? parseVideoCodec(process.env.STREAM_VIDEO_CODEC) : 'H264',
30-
31-
// Videos server options
32-
server_enabled: process.env.SERVER_ENABLED ? parseBoolean(process.env.SERVER_ENABLED) : false,
33-
server_username: process.env.SERVER_USERNAME ? process.env.SERVER_USERNAME : 'admin',
34-
server_password: bcrypt.hashSync(process.env.SERVER_PASSWORD ? process.env.SERVER_PASSWORD : 'admin', 10),
35-
server_port: parseInt(process.env.SERVER_PORT ? process.env.SERVER_PORT : '8080'),
36-
}
37-
388
function parseVideoCodec(value: string): "VP8" | "H264" | "H265" {
39-
if (typeof value === "string") {
40-
value = value.trim().toUpperCase();
41-
}
42-
if (VALID_VIDEO_CODECS.includes(value)) {
43-
return value as "VP8" | "H264" | "H265";
44-
}
45-
return "H264";
9+
if (typeof value === "string") {
10+
value = value.trim().toUpperCase();
11+
}
12+
if (VALID_VIDEO_CODECS.includes(value)) {
13+
return value as "VP8" | "H264" | "H265";
14+
}
15+
return "H264";
4616
}
4717

4818
function parsePreset(value: string): "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" {
49-
if (typeof value === "string") {
50-
value = value.trim().toLowerCase();
51-
}
52-
switch (value) {
53-
case "ultrafast":
54-
case "superfast":
55-
case "veryfast":
56-
case "faster":
57-
case "fast":
58-
case "medium":
59-
case "slow":
60-
case "slower":
61-
case "veryslow":
62-
return value as "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow";
63-
default:
64-
return "ultrafast";
65-
}
19+
if (typeof value === "string") {
20+
value = value.trim().toLowerCase();
21+
}
22+
switch (value) {
23+
case "ultrafast":
24+
case "superfast":
25+
case "veryfast":
26+
case "faster":
27+
case "fast":
28+
case "medium":
29+
case "slow":
30+
case "slower":
31+
case "veryslow":
32+
return value as "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow";
33+
default:
34+
return "ultrafast";
35+
}
6636
}
6737

6838
function parseBoolean(value: string | undefined): boolean {
69-
if (typeof value === "string") {
70-
value = value.trim().toLowerCase();
71-
}
72-
switch (value) {
73-
case "true":
74-
return true;
75-
default:
76-
return false;
77-
}
39+
if (typeof value === "string") {
40+
value = value.trim().toLowerCase();
41+
}
42+
switch (value) {
43+
case "true":
44+
return true;
45+
default:
46+
return false;
47+
}
48+
}
49+
50+
function parseAdminIds(value: string): string[] {
51+
try {
52+
// Try to parse as JSON array first
53+
const parsed = JSON.parse(value);
54+
if (Array.isArray(parsed)) {
55+
return parsed.filter(id => typeof id === 'string' && id.trim() !== '');
56+
}
57+
} catch {
58+
// If not JSON, try comma-separated values
59+
if (value.includes(',')) {
60+
return value.split(',').map(id => id.trim()).filter(id => id !== '');
61+
}
62+
}
63+
// Single value
64+
return value.trim() ? [value.trim()] : [];
65+
}
66+
67+
export default {
68+
// Selfbot options
69+
token: process.env.TOKEN || '',
70+
prefix: process.env.PREFIX || '',
71+
guildId: process.env.GUILD_ID ? process.env.GUILD_ID : '',
72+
cmdChannelId: process.env.COMMAND_CHANNEL_ID ? process.env.COMMAND_CHANNEL_ID : '',
73+
videoChannelId: process.env.VIDEO_CHANNEL_ID ? process.env.VIDEO_CHANNEL_ID : '',
74+
adminIds: process.env.ADMIN_IDS ? parseAdminIds(process.env.ADMIN_IDS) : [],
75+
76+
// General options
77+
videosDir: process.env.VIDEOS_DIR ? process.env.VIDEOS_DIR : './videos',
78+
previewCacheDir: process.env.PREVIEW_CACHE_DIR ? process.env.PREVIEW_CACHE_DIR : './tmp/preview-cache',
79+
80+
// Stream options
81+
respect_video_params: process.env.STREAM_RESPECT_VIDEO_PARAMS ? parseBoolean(process.env.STREAM_RESPECT_VIDEO_PARAMS) : false,
82+
width: process.env.STREAM_WIDTH ? parseInt(process.env.STREAM_WIDTH) : 1280,
83+
height: process.env.STREAM_HEIGHT ? parseInt(process.env.STREAM_HEIGHT) : 720,
84+
fps: process.env.STREAM_FPS ? parseInt(process.env.STREAM_FPS) : 30,
85+
bitrateKbps: process.env.STREAM_BITRATE_KBPS ? parseInt(process.env.STREAM_BITRATE_KBPS) : 1000,
86+
maxBitrateKbps: process.env.STREAM_MAX_BITRATE_KBPS ? parseInt(process.env.STREAM_MAX_BITRATE_KBPS) : 2500,
87+
hardwareAcceleratedDecoding: process.env.STREAM_HARDWARE_ACCELERATION ? parseBoolean(process.env.STREAM_HARDWARE_ACCELERATION) : false,
88+
h26xPreset: process.env.STREAM_H26X_PRESET ? parsePreset(process.env.STREAM_H26X_PRESET) : 'ultrafast',
89+
videoCodec: process.env.STREAM_VIDEO_CODEC ? parseVideoCodec(process.env.STREAM_VIDEO_CODEC) : 'H264',
90+
91+
// Videos server options
92+
server_enabled: process.env.SERVER_ENABLED ? parseBoolean(process.env.SERVER_ENABLED) : false,
93+
server_username: process.env.SERVER_USERNAME ? process.env.SERVER_USERNAME : 'admin',
94+
server_password: bcrypt.hashSync(process.env.SERVER_PASSWORD ? process.env.SERVER_PASSWORD : 'admin', 10),
95+
server_port: parseInt(process.env.SERVER_PORT ? process.env.SERVER_PORT : '8080'),
7896
}

0 commit comments

Comments
 (0)