Remove comments

This commit is contained in:
Nikhil Nawgiri 2024-08-25 04:18:21 +02:00
parent bd80625dc1
commit 3e6b798508

View file

@ -16,19 +16,14 @@ const {
openaiApiKey,
} = config;
// In order to make sure the bot doesn't lose its state between restarts, we'll give it a place to cache
// any information it needs to. You can implement your own storage provider if you like, but a JSON file
// will work fine for this example.
const storage = new SimpleFsStorageProvider(storageLocation);
const cryptoProvider = new RustSdkCryptoStorageProvider(cryptoFolderLocation);
const client = new MatrixClient(homeserverUrl, accessToken, storage, cryptoProvider);
AutojoinRoomsMixin.setupOnClient(client);
// Before we start the bot, register our command handler
client.on("room.message", handleCommand);
// Now that everything is set up, start the bot. This will start the sync loop and run until killed.
client.start().then(() => {
console.log("Bot started!")
});
@ -41,18 +36,14 @@ interface Event {
sender: string,
}
// This is the command handler we registered a few lines up
async function handleCommand(roomId: string, event: Event) {
// console.log("event:", event);
// Don't handle unhelpful events (ones that aren't text messages, are redacted, or sent by us)
if (event.content?.msgtype !== 'm.text') return;
if (event.sender === await client.getUserId()) return;
// Check to ensure that the `!hello` command is being run
const body = event.content.body;
// if (!body?.startsWith("!hello")) return;
// Now that we've passed all the checks, we can actually act upon the command
await client.setTyping(roomId, true);
const responseFromAi = await callOpenAiAPI({