setup(aibitat) {
        const folderPath = path.dirname(filename);
        // get path from filename
        if (folderPath) {
          fs.mkdirSync(folderPath, { recursive: true });
        }

        aibitat.onMessage(() => {
          const content = JSON.stringify(aibitat.chats, null, 2);
          fs.writeFile(filename, content, (err) => {
            if (err) {
              console.error(err);
            }
          });
        });
      }
Plugin to save chat history to a json file