2022-12-09 04:41:17 -05:00
|
|
|
import * as dotenv from 'dotenv';
|
|
|
|
// Support .env file
|
|
|
|
dotenv.config();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How to get access token:
|
|
|
|
* https://webapps.stackexchange.com/questions/131056/how-to-get-an-access-token-for-element-riot-matrix
|
|
|
|
*/
|
|
|
|
export const accessToken = process.env.MATRIX_ACCESS_TOKEN as string;
|
|
|
|
export const homeserverUrl = process.env.MATRIX_HOMESERVER_URL as string;
|
|
|
|
|
|
|
|
/** The full username: eg @bot:server.com */
|
|
|
|
export const matrixBotUsername = process.env.MATRIX_BOT_USERNAME as string;
|
|
|
|
export const matrixBotPassword = process.env.MATRIX_BOT_PASSWORD as string;
|
2022-12-22 09:57:34 -05:00
|
|
|
|
|
|
|
/** ChatGPT specific stuff */
|
|
|
|
export const openAiEmail = process.env.OPENAI_EMAIL as string;
|
|
|
|
export const openAiPassword = process.env.OPENAI_PASSWORD as string;
|
|
|
|
export const isGoogleLogin = Boolean(process.env.IS_GOOGLE_LOGIN) as boolean;
|
2022-12-09 04:41:17 -05:00
|
|
|
|
|
|
|
if(homeserverUrl === undefined) {
|
|
|
|
console.error("MATRIX_HOMESERVER_URL env variable is undefined");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2022-12-28 20:14:31 -05:00
|
|
|
if(accessToken === undefined) {
|
|
|
|
console.error("MATRIX_ACCESS_TOKEN env variable is undefined, set it to empty string to use username and password");
|
2022-12-09 04:41:17 -05:00
|
|
|
process.exit(1);
|
2022-12-28 20:14:31 -05:00
|
|
|
if(matrixBotUsername === undefined) {
|
|
|
|
console.error("MATRIX_BOT_USERNAME env variable is undefined, set it to empty string to use access token");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
if(matrixBotPassword === undefined) {
|
|
|
|
console.error("MATRIX_BOT_PASSWORD env variable is undefined, set it to empty string to use access token");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2022-12-09 04:41:17 -05:00
|
|
|
}
|
2022-12-22 09:57:34 -05:00
|
|
|
if(openAiEmail === undefined) {
|
|
|
|
console.error("OPENAI_EMAIL env variable is undefined");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
if(openAiPassword === undefined) {
|
|
|
|
console.error("OPENAI_PASSWORD env variable is undefined");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
if(isGoogleLogin === undefined) {
|
|
|
|
console.error("IS_GOOGLE_LOGIN env variable is undefined");
|
2022-12-09 04:41:17 -05:00
|
|
|
process.exit(1);
|
|
|
|
}
|