35 lines
1013 B
JavaScript
35 lines
1013 B
JavaScript
const config = {
|
|
token: process.env.BOT_TOKEN,
|
|
admins: process.env.ADMIN_LIST?.split(/\s*,\s*/g).map((x) => +x) ?? [],
|
|
allFormats: false,
|
|
mtproto: {
|
|
apiId: +process.env.API_ID,
|
|
apiHash: process.env.API_HASH,
|
|
session: process.env.API_SESSION,
|
|
chatId: +process.env.CHAT_ID,
|
|
},
|
|
};
|
|
config.whitelist = [].concat(
|
|
process.env.WHITELIST?.split(/\s*,\s*/g).map((x) => +x) ?? [],
|
|
config.admins,
|
|
);
|
|
config.whitelist = Object.keys(
|
|
Object.fromEntries(config.whitelist.map((x) => [x, true])),
|
|
).map((x) => +x);
|
|
|
|
if (!config.mtproto.apiId || !config.mtproto.apiHash || !config.mtproto.session || !config.mtproto.chatId) {
|
|
config.mtproto = null;
|
|
}
|
|
|
|
console.info(config);
|
|
if (!process.env.BOT_TOKEN) {
|
|
throw new Error(
|
|
"BOT_TOKEN not defined. Please, run docker container: docker run --env-file .env <params> <container>",
|
|
);
|
|
}
|
|
|
|
config.admins = Object.fromEntries(config.admins.map((x) => [x, true]));
|
|
config.whitelist = Object.fromEntries(config.whitelist.map((x) => [x, true]));
|
|
|
|
module.exports = config;
|