mirror of
https://github.com/matrixgpt/matrix-chatgpt-bot.git
synced 2024-09-30 04:55:44 +00:00
Add support for refreshing ChatGPT sessions regularly
Call `api.refreshSession()` every hour to refresh the ChatGPT session Call `api.resetSession()` every 24 hours to reset the ChatGPT session
This commit is contained in:
parent
2a5845c954
commit
6bf0a56560
19
src/index.ts
19
src/index.ts
@ -49,7 +49,24 @@ async function main() {
|
|||||||
isMicrosoftLogin: (OPENAI_LOGIN_TYPE == "microsoft"),
|
isMicrosoftLogin: (OPENAI_LOGIN_TYPE == "microsoft"),
|
||||||
isProAccount: OPENAI_PRO
|
isProAccount: OPENAI_PRO
|
||||||
})
|
})
|
||||||
await chatGPT.initSession()
|
|
||||||
|
chatGPT.initSession().then(() => {
|
||||||
|
LogService.info('ChatGPT session initialized');
|
||||||
|
});
|
||||||
|
|
||||||
|
// call `api.refreshSession()` every hour to refresh the session
|
||||||
|
setInterval(() => {
|
||||||
|
chatGPT.refreshSession().then(() => {
|
||||||
|
LogService.info('ChatGPT session reset');
|
||||||
|
});
|
||||||
|
}, 60 * 60 * 1000);
|
||||||
|
|
||||||
|
// call `api.resetSession()` every 24 hours to reset the session
|
||||||
|
setInterval(() => {
|
||||||
|
chatGPT.resetSession().then(() => {
|
||||||
|
LogService.info('ChatGPT session reset');
|
||||||
|
});
|
||||||
|
}, 24 * 60 * 60 * 1000);
|
||||||
|
|
||||||
// Automatically join rooms the bot is invited to
|
// Automatically join rooms the bot is invited to
|
||||||
if (MATRIX_AUTOJOIN) {
|
if (MATRIX_AUTOJOIN) {
|
||||||
|
Loading…
Reference in New Issue
Block a user