Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Add support for pro account
Browse files Browse the repository at this point in the history
  • Loading branch information
bertybuttface committed Jan 24, 2023
1 parent f5e030b commit e8efc4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ OPENAI_EMAIL=
OPENAI_PASSWORD=
# What type of Login it is, possibility's are google, openai, microsoft
OPENAI_LOGIN_TYPE=google
# Set the next line to true if you are using a ChatGPT pro account.
OPENAI_PRO=false
# Matrix Static Settings (required, see notes)
# Defaults to "https://matrix.org"
Expand Down
2 changes: 2 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const {
OPENAI_EMAIL,
OPENAI_PASSWORD,
OPENAI_LOGIN_TYPE,
OPENAI_PRO,
CHATGPT_TIMEOUT
} = parseEnv(process.env, {
DATA_PATH: { schema: z.string().default("./storage"), description: "Set to /storage/ if using docker, ./storage if running without" },
Expand All @@ -50,5 +51,6 @@ export const {
OPENAI_EMAIL: { schema: z.string().min(3), description: "Set full username of OpenAI's account" },
OPENAI_PASSWORD: { schema: z.string().min(1), description: "Set password of OpenAI's account" },
OPENAI_LOGIN_TYPE: { schema: z.enum(["google", "openai", "microsoft"]).default("google"), description: "Set authentication provider to 'google', 'openai' or 'microsoft'" },
OPENAI_PRO: { schema: z.boolean().default(false), description: "Set to true if you have a paid ChatGPT subscription." },
CHATGPT_TIMEOUT: { schema: z.number().default(2 * 60 * 1000), description: "Set number of milliseconds to wait for CHATGPT responses" }
});
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "matrix-bot-sdk";

import * as path from "path";
import { DATA_PATH, OPENAI_EMAIL, OPENAI_PASSWORD, OPENAI_LOGIN_TYPE, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_BOT_PASSWORD, MATRIX_BOT_USERNAME, MATRIX_ENCRYPTION } from './env.js'
import { DATA_PATH, OPENAI_EMAIL, OPENAI_PASSWORD, OPENAI_LOGIN_TYPE, OPENAI_PRO, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_BOT_PASSWORD, MATRIX_BOT_USERNAME, MATRIX_ENCRYPTION } from './env.js'
import { parseMatrixUsernamePretty } from './utils.js';
import CommandHandler from "./handlers.js"
import { ChatGPTAPIBrowser } from 'chatgpt'
Expand Down Expand Up @@ -45,7 +45,8 @@ async function main() {
email: OPENAI_EMAIL,
password: OPENAI_PASSWORD,
isGoogleLogin: (OPENAI_LOGIN_TYPE == "google"),
isMicrosoftLogin: (OPENAI_LOGIN_TYPE == "microsoft")
isMicrosoftLogin: (OPENAI_LOGIN_TYPE == "microsoft"),
isProAccount: OPENAI_PRO
})
await chatGPT.initSession()

Expand Down

0 comments on commit e8efc4d

Please sign in to comment.