-
Notifications
You must be signed in to change notification settings - Fork 771
Expand file tree
/
Copy pathConfigurations.js
More file actions
70 lines (62 loc) · 2.2 KB
/
Configurations.js
File metadata and controls
70 lines (62 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import dotenv from "dotenv";
dotenv.config({ override: true });
// Strip inline # comments that some env injectors (e.g. vestauth) leave in the value,
// then trim surrounding whitespace.
// Example: "mykey #old-key # note" → "mykey"
const stripEnv = (val, fallback = "") => {
if (!val) return fallback;
return val.split("#")[0].trim() || fallback;
};
// Parse a comma-separated env value into a cleaned array, dropping known placeholders
const parseKeys = (envVal, ...placeholders) => {
if (!envVal) return [];
return envVal
.split(",")
.map((k) => k.trim())
.filter((k) => k && !placeholders.includes(k));
};
// Pick a random key from a pool; returns null when pool is empty
global.pickKey = (keys) => {
if (!keys || keys.length === 0) return null;
return keys[Math.floor(Math.random() * keys.length)];
};
let gg = process.env.MODS;
if (!gg) {
gg = "918101187835"; // You can replace this number with yours //
}
global.owner = gg.split(",");
global.mongodb = process.env.MONGODB || "mongodb://localhost:27017/atlas";
global.sessionId = stripEnv(process.env.SESSION_ID, "ok");
global.prefa = stripEnv(process.env.PREFIX, "-");
global.packname = stripEnv(process.env.PACKNAME, `Atlas Bot`);
global.author = stripEnv(process.env.AUTHOR, "by: Team Atlas");
global.port = stripEnv(process.env.PORT, "10000");
// Multi-key pools — comma-separate as many keys as you want in .env
global.geminiAPIKeys = parseKeys(
process.env.GEMINI_API,
"Put your gemini API key here",
"your-gemini-api-key-here",
);
global.openAiAPIKeys = parseKeys(
process.env.OPENAI_API,
"Put your openai API key here",
"sk-...put your OpenAI API key",
);
global.claudeAPIKeys = parseKeys(
process.env.CLAUDE_API,
"Put your claude API key here",
"your-anthropic-api-key-here",
);
global.tenorAPIKeys = parseKeys(
process.env.TENOR_API_KEY || "AIzaSyCyouca1_KKy4W_MG1xsPzuku5oa8W358c",
);
// Dynamic getter — every access to `tenorApiKey` (used in Plugins) returns a random key from the pool
Object.defineProperty(global, "tenorApiKey", {
get() {
return global.pickKey(global.tenorAPIKeys) || "AIzaSyCyouca1_KKy4W_MG1xsPzuku5oa8W358c";
},
configurable: true,
});
export default {
mongodb: global.mongodb,
};