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

Commit c7a9556

Browse files
committed
Add MATRIX_WELCOME so notice can be turned off
1 parent cb028c2 commit c7a9556

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const {
1919
MATRIX_THREADS,
2020
MATRIX_PREFIX_DM,
2121
MATRIX_RICH_TEXT,
22+
MATRIX_WELCOME,
2223
/** Matrix Access Control */
2324
MATRIX_BLACKLIST,
2425
MATRIX_WHITELIST,
@@ -48,6 +49,7 @@ export const {
4849
MATRIX_THREADS: { schema: z.boolean().default(true), description: "Set to true if you want the bot to answer always in a new thread/conversation" },
4950
MATRIX_PREFIX_DM: { schema: z.boolean().default(false), description: "Set to false if you want the bot to answer to all messages in a one-to-one room" },
5051
MATRIX_RICH_TEXT: { schema: z.boolean().default(true), description: "Set to true if you want the bot to answer with enriched text" },
52+
MATRIX_WELCOME: { schema: z.boolean().default(true), description: "Set to true if you want the bot to post a message when it joins a new chat." },
5153
/** Matrix Access Control */
5254
MATRIX_BLACKLIST: { schema: z.string().optional(), description: "Set to a spaces separated string of 'user:homeserver' or a wildcard like ':anotherhomeserver.example' to blacklist users or domains" },
5355
MATRIX_WHITELIST: { schema: z.string().optional(), description: "Set to a spaces separated string of 'user:homeserver' or a wildcard like ':anotherhomeserver.example' to whitelist users or domains" },

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "matrix-bot-sdk";
88

99
import * as path from "path";
10-
import { DATA_PATH, KEYV_URL, OPENAI_API_KEY, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_BOT_PASSWORD, MATRIX_BOT_USERNAME, MATRIX_ENCRYPTION, MATRIX_THREADS, CHATGPT_CONTEXT, CHATGPT_MODEL, KEYV_BOT_STORAGE, KEYV_BACKEND, CHATGPT_PROMPT_PREFIX } from './env.js'
10+
import { DATA_PATH, KEYV_URL, OPENAI_API_KEY, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_BOT_PASSWORD, MATRIX_BOT_USERNAME, MATRIX_ENCRYPTION, MATRIX_THREADS, CHATGPT_CONTEXT, CHATGPT_MODEL, KEYV_BOT_STORAGE, KEYV_BACKEND, CHATGPT_PROMPT_PREFIX, MATRIX_WELCOME } from './env.js'
1111
import CommandHandler from "./handlers.js"
1212
import { KeyvStorageProvider } from './storage.js'
1313
import { parseMatrixUsernamePretty, wrapPrompt } from './utils.js';
@@ -70,10 +70,12 @@ async function main() {
7070

7171
client.on("room.join", async (roomId: string, _event: any) => {
7272
LogService.info("index", `Bot joined room ${roomId}`);
73-
await client.sendMessage(roomId, {
74-
"msgtype": "m.notice",
75-
"body": `👋 Hello, I'm ChatGPT bot! Matrix E2EE: ${MATRIX_ENCRYPTION}`,
76-
});
73+
if(MATRIX_WELCOME) {
74+
await client.sendMessage(roomId, {
75+
"msgtype": "m.notice",
76+
"body": `👋 Hello, I'm ChatGPT bot! Matrix E2EE: ${MATRIX_ENCRYPTION}`,
77+
});
78+
}
7779
});
7880

7981
// Prepare the command handler

0 commit comments

Comments
 (0)