From 7e436d514f4ba9617622b2b4304f2a3f5b001b2a Mon Sep 17 00:00:00 2001 From: Vicente Date: Tue, 15 Oct 2024 23:00:26 -0300 Subject: [PATCH 01/12] Removed "setup.sh" script This file is no longer needed as it can now be run using the console command "npm run start" --- package.json | 2 +- setup.sh | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 setup.sh diff --git a/package.json b/package.json index 33a996b..e80104e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "MIT", "scripts": { "dev": "vite-node ./src/index.ts", - "start": "npx yarn dev", + "start": "npx yarn && npx yarn dev", "format": "prettier --write ./src", "test": "vite-node ./test/index.test.ts", "test:baileys": "vite-node ./baileys/index.ts", diff --git a/setup.sh b/setup.sh deleted file mode 100644 index e64671d..0000000 --- a/setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -echo "installing dependencies" -npx yarn -echo "✔ dependencies has been installed" - -echo "initializing server" -npx yarn dev - From 64e9585e94ea1da836395b6245755460d208b092 Mon Sep 17 00:00:00 2001 From: Vicente Date: Tue, 15 Oct 2024 23:01:01 -0300 Subject: [PATCH 02/12] Update readme.md The format was updated with the current standard --- readme.md | 201 +++++++++++++++--------------------------------------- 1 file changed, 55 insertions(+), 146 deletions(-) diff --git a/readme.md b/readme.md index 32b81ba..21c52d5 100644 --- a/readme.md +++ b/readme.md @@ -1,102 +1,13 @@ -```diff -+ We are switching to the @whiskeysockets/baileys library for our bot because it's lightweight and easy to deploy. -- This branch is still under construction 🚧. Currently, we only support the models listed below, but support for new models will be added soon. -``` - -**Supported Models:** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ModelProviderTypeUsage
Chat GPTOpen AItext to text!chatgpt
GeminiGoogletext to text!gemini
Gemini VisionGoogleimage to text!gemini-vision
Dalle 2Open AItext to image!dalle
Dalle 3Open AItext to image + revised text!dalle3
FLUX.1-schnellHugging Facetext to image!flux
- -**Useful links:** - - - - - - - - - - - - - - - - - - -
♥ Sponsor💎 Bounty🚀 Deployment✉ WhatsApp Group
- - link - - - - link - - - - link - - - link -
- -
+> [!NOTE] +> We are switching to the @whiskeysockets/baileys library for our bot because it's lightweight and easy to deploy. +> +> This branch is still under construction 🚧. Currently, we only support the models listed below, but support for new models will be added soon.
-

- -WhatsApp AI Bot 🚀

+# WhatsApp AI Bot 🚀 +
The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses to user input. The bot supports several AI models, including **`Gemini`**, **`Gemini-Vision`**, **`CHAT-GPT`**, **`DALL-E`**, and **`Stability AI`**, and users can also create their **`own models`** to customize the bot's behavior. @@ -112,23 +23,50 @@ The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses - [Sponsors.](#Sponsors) - [About.](#about-us) +# Supported Models + +| Model | Provider | Type | Command | +| ----- | -------- | ---- | ------- | +| ChatGPT | [OpenAI](https://platform.openai.com/docs/guides/text-generation/quickstart) | Text to Text | !chatgpt | +| Gemini | [Google](https://ai.google.dev/gemini-api/docs/text-generation?lang=node#generate-text-from-text) | Text to Text | !gemini | +| Gemini Vision | [Google](https://ai.google.dev/gemini-api/docs/vision?lang=node#upload-image) | Image to Text | none | +| Dalle 2 & 3 | [OpenAI](https://platform.openai.com/docs/api-reference/images/create) | Text to Image | !dalle | + # Demo -**Gemini** +### Gemini + +
+Click to see the demo [![Screenshot (1186)](https://github.com/Zain-ul-din/whatsapp-ai-bot/assets/78583049/b6f256de-c792-4947-bf65-401a60a0b1f4)](https://www.youtube.com/watch?v=dXDxTQQqeq8) -**Stability AI + Chat-GPT** +
+ +### Stability AI + Chat-GPT + +
+Click to see the demo ![image](https://user-images.githubusercontent.com/78583049/222071673-ef0f2021-a8b4-4263-9304-a77ecd76c0a1.png) -**Dalle + Custom Model** +
+ +### Dalle + Custom Model + +
+ +Click to see the demo ![image](https://user-images.githubusercontent.com/78583049/222074174-55792d13-5137-4c1c-b708-3ad188ca8d8d.png) +
+ +--- + # Usage -**1. Download Source Code** +### 1. Download Source Code ```bash git clone https://github.com/Zain-ul-din/WhatsApp-Ai-bot.git @@ -139,32 +77,23 @@ The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses - [Download Zip File](https://github.com/Zain-ul-din/WhatsApp-Ai-bot/archive/refs/heads/master.zip) -**2. Get API Keys** +### 2. Get API Keys -- [Gemini API Key](https://makersuite.google.com/app/apikey) -- [OpenAI API Key](https://platform.openai.com/account/api-keys) -- [StabilityAI API Key](https://platform.stability.ai/docs/getting-started/authentication) +- [Gemini API Key](https://aistudio.google.com/app/apikey) +- [OpenAI API Key](https://platform.openai.com/api-keys) +- [StabilityAI API Key](https://platform.stability.ai/account/keys) -**3. Add API Keys** +### 3. Add API Keys -- create `.env` in the root of the project. +Copy the file `.env.example` and rename it to `.env`, then set any settings you want to change. -- set following fields in `.env` file +### 4. Run the code -```.env - OPENAI_API_KEY=YOUR_OPEN_AI_API_KEY - DREAMSTUDIO_API_KEY=YOUR_STABILITY_AI_API_KEY - GEMINI_API_KEY=YOUR_GEMINI_API_KEY - HF_TOKEN=HUGGING_FACE_TOKEN -``` - -**4. Run the code** - -- run `setup.sh` to start the bot. +- Run `setup.sh` to start the bot - Scan QR code. -**Default Prefix** +# Default Settings - `!gemini` use gemini. - `!gemini-vision` use `gemini-pro-vision` model for images @@ -209,35 +138,15 @@ This bot utilizes Puppeteer to operate an actual instance of Whatsapp Web to pre A big thank you to these people for supporting this project. - - - - - - - - - - - - - - - -
- - - - - -
- Levitco - 💎 - - Anas Ashfaq - - YOU? -
+| ![Levitco](https://avatars.githubusercontent.com/u/47256157?v=4&s=128) | ![Anas Ashfaq](https://avatars.githubusercontent.com/u/119153707?v=4&s=128) | | +| --- | --- | --- | +| Levitco | Anas Ashfaq | YOU? | + +# Useful links + +| ♥ Sponsor | 💎 Bounty | 🚀 Deployment | ✉ WhatsApp Group | +| ------- | ------ | ---------- | --------------- | +| [Link](https://buymeacoffee.com/zainuldin) | [Link](https://wa-ai-seven.vercel.app/feat-req) | [Link](https://wa-ai-seven.vercel.app/) | [Link](https://chat.whatsapp.com/DlVCpX2QQNx6jHQVT9IB7Z) | ## About Us From c4aa953539bd2c071a9b8df884d28057d5e04681 Mon Sep 17 00:00:00 2001 From: Vicente Date: Tue, 15 Oct 2024 23:04:33 -0300 Subject: [PATCH 03/12] Update readme.md Quick change --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 21c52d5..9022def 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ > [!NOTE] -> We are switching to the @whiskeysockets/baileys library for our bot because it's lightweight and easy to deploy. +> We are switching to the [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys) library for our bot because it's lightweight and easy to deploy. > > This branch is still under construction 🚧. Currently, we only support the models listed below, but support for new models will be added soon. From a1baa946dfb871a2dbf4d2d9189415610d8f7027 Mon Sep 17 00:00:00 2001 From: Vicente Date: Wed, 16 Oct 2024 13:47:28 -0300 Subject: [PATCH 04/12] Update table of contents in readme.md --- readme.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 9022def..dcb1950 100644 --- a/readme.md +++ b/readme.md @@ -14,14 +14,14 @@ The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses # Table of Content -- [Demo.](#demo) -- [Usage.](#usage) -- [Tutorials.](#Tutorials) -- [Docs.](https://github.com/Zain-ul-din/WhatsApp-Ai-bot/blob/master/docs/config-docs.md) -- [Disclaimer.](#disclaimer) -- [Contributors.](#contributors) -- [Sponsors.](#Sponsors) -- [About.](#about-us) +- [Demo](#demo) +- [Usage](#usage) +- [Tutorials](#Tutorials) +- [Docs](docs/config-docs.md) +- [Disclaimer](#disclaimer) +- [Contributors](#contributors) +- [Sponsors](#Sponsors) +- [About](#about-us) # Supported Models From 0c3306d44032cad445e98fc3fd060abf6ee68a39 Mon Sep 17 00:00:00 2001 From: Vicente Date: Wed, 16 Oct 2024 15:30:31 -0300 Subject: [PATCH 05/12] Update Docs Link in readme.md --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index dcb1950..3af8880 100644 --- a/readme.md +++ b/readme.md @@ -106,7 +106,7 @@ Copy the file `.env.example` and rename it to `.env`, then set any settings you **Note! open `src/whatsapp-ai.config.ts` to edit config.** -[Docs Link](https://github.com/Zain-ul-din/WhatsApp-Ai-bot/blob/master/docs/config-docs.md) +[Docs Link](docs/config-docs.md) # Tutorials @@ -129,8 +129,8 @@ This bot utilizes Puppeteer to operate an actual instance of Whatsapp Web to pre ### -- [Open issue here](https://github.com/Zain-ul-din/WhatsApp-Ai-bot/issues) -- [Ask Question here](https://github.com/Zain-ul-din/WhatsApp-Ai-bot/discussions) +- [Open issue here](issues) +- [Ask Question here](discussions) From 4af69be288d546e69979e552d517f4e0335b3fa6 Mon Sep 17 00:00:00 2001 From: Vicente Date: Wed, 16 Oct 2024 15:39:32 -0300 Subject: [PATCH 06/12] Fixed and added relative links in README.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3af8880..20e0213 100644 --- a/readme.md +++ b/readme.md @@ -129,8 +129,8 @@ This bot utilizes Puppeteer to operate an actual instance of Whatsapp Web to pre ### -- [Open issue here](issues) -- [Ask Question here](discussions) +- [Open issue here](./../../issues) +- [Ask Question here](./../../discussions) From 3e2db91befce1a20c14c927f7bbad95ce1a8e942 Mon Sep 17 00:00:00 2001 From: Vicente Date: Wed, 16 Oct 2024 15:40:03 -0300 Subject: [PATCH 07/12] Rename readme.md to README.md --- readme.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.md => README.md (100%) diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md From 5bb8f903ac200278dd5e619f5c872bb1639cd367 Mon Sep 17 00:00:00 2001 From: Vicente Date: Wed, 16 Oct 2024 23:17:38 -0300 Subject: [PATCH 08/12] Delete yarn.lock Reason: The file autogenerate itself in every install --- yarn.lock | 1630 ----------------------------------------------------- 1 file changed, 1630 deletions(-) delete mode 100644 yarn.lock diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 24614cf..0000000 --- a/yarn.lock +++ /dev/null @@ -1,1630 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@adiwajshing/keyed-db@^0.2.4": - version "0.2.4" - resolved "https://registry.npmjs.org/@adiwajshing/keyed-db/-/keyed-db-0.2.4.tgz" - integrity sha512-yprSnAtj80/VKuDqRcFFLDYltoNV8tChNwFfIgcf6PGD4sjzWIBgs08pRuTqGH5mk5wgL6PBRSsMCZqtZwzFEw== - -"@babel/code-frame@^7.0.0": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz" - integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== - dependencies: - "@babel/highlight" "^7.18.6" - -"@babel/helper-validator-identifier@^7.18.6": - version "7.19.1" - resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz" - integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== - -"@babel/highlight@^7.18.6": - version "7.18.6" - resolved "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz" - integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== - dependencies: - "@babel/helper-validator-identifier" "^7.18.6" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@esbuild/android-arm64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz#984b4f9c8d0377443cc2dfcef266d02244593622" - integrity sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ== - -"@esbuild/android-arm@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.18.20.tgz#fedb265bc3a589c84cc11f810804f234947c3682" - integrity sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw== - -"@esbuild/android-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.18.20.tgz#35cf419c4cfc8babe8893d296cd990e9e9f756f2" - integrity sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg== - -"@esbuild/darwin-arm64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz#08172cbeccf95fbc383399a7f39cfbddaeb0d7c1" - integrity sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA== - -"@esbuild/darwin-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz#d70d5790d8bf475556b67d0f8b7c5bdff053d85d" - integrity sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ== - -"@esbuild/freebsd-arm64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz#98755cd12707f93f210e2494d6a4b51b96977f54" - integrity sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw== - -"@esbuild/freebsd-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz#c1eb2bff03915f87c29cece4c1a7fa1f423b066e" - integrity sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ== - -"@esbuild/linux-arm64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz#bad4238bd8f4fc25b5a021280c770ab5fc3a02a0" - integrity sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA== - -"@esbuild/linux-arm@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz#3e617c61f33508a27150ee417543c8ab5acc73b0" - integrity sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg== - -"@esbuild/linux-ia32@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz#699391cccba9aee6019b7f9892eb99219f1570a7" - integrity sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA== - -"@esbuild/linux-loong64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz#e6fccb7aac178dd2ffb9860465ac89d7f23b977d" - integrity sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg== - -"@esbuild/linux-mips64el@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz#eeff3a937de9c2310de30622a957ad1bd9183231" - integrity sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ== - -"@esbuild/linux-ppc64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz#2f7156bde20b01527993e6881435ad79ba9599fb" - integrity sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA== - -"@esbuild/linux-riscv64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz#6628389f210123d8b4743045af8caa7d4ddfc7a6" - integrity sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A== - -"@esbuild/linux-s390x@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz#255e81fb289b101026131858ab99fba63dcf0071" - integrity sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ== - -"@esbuild/linux-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz#c7690b3417af318a9b6f96df3031a8865176d338" - integrity sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w== - -"@esbuild/netbsd-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz#30e8cd8a3dded63975e2df2438ca109601ebe0d1" - integrity sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A== - -"@esbuild/openbsd-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz#7812af31b205055874c8082ea9cf9ab0da6217ae" - integrity sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg== - -"@esbuild/sunos-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz#d5c275c3b4e73c9b0ecd38d1ca62c020f887ab9d" - integrity sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ== - -"@esbuild/win32-arm64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz#73bc7f5a9f8a77805f357fab97f290d0e4820ac9" - integrity sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg== - -"@esbuild/win32-ia32@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz#ec93cbf0ef1085cc12e71e0d661d20569ff42102" - integrity sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g== - -"@esbuild/win32-x64@0.18.20": - version "0.18.20" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz#786c5f41f043b07afb1af37683d7c33668858f6d" - integrity sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ== - -"@eshaz/web-worker@1.2.2": - version "1.2.2" - resolved "https://registry.npmjs.org/@eshaz/web-worker/-/web-worker-1.2.2.tgz" - integrity sha512-WxXiHFmD9u/owrzempiDlBB1ZYqiLnm9s6aPc8AlFQalq2tKmqdmMr9GXOupDgzXtqnBipj8Un0gkIm7Sjf8mw== - -"@google/generative-ai@^0.17.1": - version "0.17.1" - resolved "https://registry.npmjs.org/@google/generative-ai/-/generative-ai-0.17.1.tgz" - integrity sha512-TgWz02c5l2XJlEDys81UVat5+Qg9xqmYah7tQt6xlsBwFvzIFPz64aZFGd1av2sxT22NsssqLATjNsusAIJICA== - -"@hapi/boom@^9.1.3": - version "9.1.4" - resolved "https://registry.npmjs.org/@hapi/boom/-/boom-9.1.4.tgz" - integrity sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw== - dependencies: - "@hapi/hoek" "9.x.x" - -"@hapi/hoek@9.x.x": - version "9.3.0" - resolved "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz" - integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ== - -"@improbable-eng/grpc-web-node-http-transport@^0.15.0": - version "0.15.0" - resolved "https://registry.npmjs.org/@improbable-eng/grpc-web-node-http-transport/-/grpc-web-node-http-transport-0.15.0.tgz" - integrity sha512-HLgJfVolGGpjc9DWPhmMmXJx8YGzkek7jcCFO1YYkSOoO81MWRZentPOd/JiKiZuU08wtc4BG+WNuGzsQB5jZA== - -"@improbable-eng/grpc-web@^0.15.0": - version "0.15.0" - resolved "https://registry.npmjs.org/@improbable-eng/grpc-web/-/grpc-web-0.15.0.tgz" - integrity sha512-ERft9/0/8CmYalqOVnJnpdDry28q+j+nAlFFARdjyxXDJ+Mhgv9+F600QC8BR9ygOfrXRlAk6CvST2j+JCpQPg== - dependencies: - browser-headers "^0.4.1" - -"@mongodb-js/saslprep@^1.1.5": - version "1.1.9" - resolved "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz" - integrity sha512-tVkljjeEaAhCqTzajSdgbQ6gE6f3oneVwa3iXR6csiEwXXOFsiC6Uh9iAjAhXPtqa/XMDHWjjeNH/77m/Yq2dw== - dependencies: - sparse-bitfield "^3.0.3" - -"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": - version "1.1.2" - resolved "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz" - integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@protobufjs/eventemitter@^1.1.0": - version "1.1.0" - resolved "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz" - integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== - -"@protobufjs/fetch@^1.1.0": - version "1.1.0" - resolved "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz" - integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@protobufjs/float@^1.0.2": - version "1.0.2" - resolved "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz" - integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== - -"@protobufjs/inquire@^1.1.0": - version "1.1.0" - resolved "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz" - integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== - -"@protobufjs/path@^1.1.2": - version "1.1.2" - resolved "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz" - integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== - -"@protobufjs/pool@^1.1.0": - version "1.1.0" - resolved "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz" - integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== - -"@protobufjs/utf8@^1.1.0": - version "1.1.0" - resolved "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz" - integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== - -"@thi.ng/bitstream@^2.2.12": - version "2.4.0" - resolved "https://registry.npmjs.org/@thi.ng/bitstream/-/bitstream-2.4.0.tgz" - integrity sha512-0wQLNydySw4nOe+yGdJA1SmztWnDlf2WimuJWQpeh5+K3L/snxJx+rfvgjbfq/rkMiHhmvD/VywHLwI0vYWMLQ== - dependencies: - "@thi.ng/errors" "^2.5.15" - -"@thi.ng/errors@^2.5.15": - version "2.5.15" - resolved "https://registry.npmjs.org/@thi.ng/errors/-/errors-2.5.15.tgz" - integrity sha512-vQ0M3yf6UbB8k6rdQMo2zgFpvcvEl95aLA1y5Fhxtm1KU6JfzDO1YZL3eIYPPnzhjUHw9zc0htbeBLI1x2QDnw== - -"@tokenizer/token@^0.3.0": - version "0.3.0" - resolved "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz" - integrity sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A== - -"@types/long@^4.0.0": - version "4.0.2" - resolved "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz" - integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== - -"@types/node-fetch@^2.6.2": - version "2.6.2" - resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz" - integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - -"@types/node-fetch@^2.6.4": - version "2.6.11" - resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz" - integrity sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g== - dependencies: - "@types/node" "*" - form-data "^4.0.0" - -"@types/node@*", "@types/node@^18.14.0": - version "18.14.0" - resolved "https://registry.npmjs.org/@types/node/-/node-18.14.0.tgz" - integrity sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A== - -"@types/node@>=13.7.0": - version "22.5.0" - resolved "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz" - integrity sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg== - dependencies: - undici-types "~6.19.2" - -"@types/node@^10.1.0": - version "10.17.60" - resolved "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz" - integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== - -"@types/node@^18.11.18": - version "18.19.39" - resolved "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz" - integrity sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ== - dependencies: - undici-types "~5.26.4" - -"@types/normalize-package-data@^2.4.0": - version "2.4.1" - resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz" - integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== - -"@types/qrcode-terminal@^0.12.0": - version "0.12.0" - resolved "https://registry.npmjs.org/@types/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz" - integrity sha512-g0fQKl3IVnUePV8tLkiBTduxAVSZsXts444T2aMfjOEGxd7XoeSIs16/AmRe2NlcJLqbvsOBSXov7dKSo4wigA== - -"@types/webidl-conversions@*": - version "7.0.3" - resolved "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz" - integrity sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA== - -"@types/whatwg-url@^11.0.2": - version "11.0.5" - resolved "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz" - integrity sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ== - dependencies: - "@types/webidl-conversions" "*" - -"@wasm-audio-decoders/common@9.0.4": - version "9.0.4" - resolved "https://registry.npmjs.org/@wasm-audio-decoders/common/-/common-9.0.4.tgz" - integrity sha512-+XdSt6mMfvir5D+vcW8gLqledJIgzkBAGXOG7ySJtbKdOTHduG2YAHvUNH9/Mb2hkiM8U9EJrGA6HhbsqG/bbg== - dependencies: - "@eshaz/web-worker" "1.2.2" - -"@wasm-audio-decoders/common@9.0.5": - version "9.0.5" - resolved "https://registry.npmjs.org/@wasm-audio-decoders/common/-/common-9.0.5.tgz" - integrity sha512-b9JNh9sPAvn8PVIizNh9D60WkfQong/u9ea873H47u7zvVDLctxYIp2aZw9CQqXaQdk7JB3MoU5UHiseO40swg== - dependencies: - "@eshaz/web-worker" "1.2.2" - simple-yenc "^1.0.4" - -"@wasm-audio-decoders/flac@^0.2.1": - version "0.2.4" - resolved "https://registry.npmjs.org/@wasm-audio-decoders/flac/-/flac-0.2.4.tgz" - integrity sha512-bsUlwIjd5y+IAEyILCQdi8y0LocKEkZ0enA8ljDL+NVVwN+5Rv5Xkm/HcdUxnB7MtekxN2cNcTsv1zkb2aZyWg== - dependencies: - "@wasm-audio-decoders/common" "9.0.5" - codec-parser "2.4.3" - -"@wasm-audio-decoders/ogg-vorbis@^0.1.12": - version "0.1.15" - resolved "https://registry.npmjs.org/@wasm-audio-decoders/ogg-vorbis/-/ogg-vorbis-0.1.15.tgz" - integrity sha512-skAN3NIrRzMkVouyfyq3gYT/op/K9iutMZr7kr5/9fnIaCnpYdrdbv69X8PZ6y3K2J5zy5KuGno5kzH8yGLOOg== - dependencies: - "@wasm-audio-decoders/common" "9.0.5" - codec-parser "2.4.3" - -"@whiskeysockets/baileys@*", "@whiskeysockets/baileys@^6.7.7": - version "6.7.7" - resolved "https://registry.npmjs.org/@whiskeysockets/baileys/-/baileys-6.7.7.tgz" - integrity sha512-QWF+D/+bxGvh5xvFJUOXeZ0UTgbm6LEUVXeHtDHYL8wCeK2ND5qnbGrOEFC7LJzhnOhaJZA/N0v3SutpH7zKYw== - dependencies: - "@adiwajshing/keyed-db" "^0.2.4" - "@hapi/boom" "^9.1.3" - async-lock "^1.4.1" - audio-decode "^2.1.3" - axios "^1.6.0" - cache-manager "4.0.1" - futoin-hkdf "^1.5.1" - libphonenumber-js "^1.10.20" - libsignal "github:WhiskeySockets/libsignal-node" - lodash "^4.17.21" - music-metadata "^7.12.3" - node-cache "^5.1.2" - pino "^7.0.0" - protobufjs "^7.2.4" - uuid "^10.0.0" - ws "^8.13.0" - -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - -acorn@^8.8.2: - version "8.8.2" - resolved "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== - -agentkeepalive@^4.2.1: - version "4.5.0" - resolved "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz" - integrity sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew== - dependencies: - humanize-ms "^1.2.1" - -ansi-regex@^4.1.0: - version "4.1.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz" - integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -async-lock@^1.4.1: - version "1.4.1" - resolved "https://registry.npmjs.org/async-lock/-/async-lock-1.4.1.tgz" - integrity sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ== - -async@3.2.3: - version "3.2.3" - resolved "https://registry.npmjs.org/async/-/async-3.2.3.tgz" - integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -atomic-sleep@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz" - integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== - -audio-buffer@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/audio-buffer/-/audio-buffer-5.0.0.tgz" - integrity sha512-gsDyj1wwUp8u7NBB+eW6yhLb9ICf+0eBmDX8NGaAS00w8/fLqFdxUlL5Ge/U8kB64DlQhdonxYC59dXy1J7H/w== - -audio-decode@^2.1.3: - version "2.2.0" - resolved "https://registry.npmjs.org/audio-decode/-/audio-decode-2.2.0.tgz" - integrity sha512-3SLGQ4VL57+fuFHV5JBeTNx3frjdztOIm4LJBFqiFhMQGeerrcS3WQbfuPPOqcNmqFGmPeaAAFPCxF75cSK/pQ== - dependencies: - "@wasm-audio-decoders/flac" "^0.2.1" - "@wasm-audio-decoders/ogg-vorbis" "^0.1.12" - audio-buffer "^5.0.0" - audio-type "^2.2.1" - mpg123-decoder "^0.4.10" - node-wav "^0.0.2" - ogg-opus-decoder "^1.6.8" - qoa-format "^1.0.1" - -audio-type@^2.2.1: - version "2.2.1" - resolved "https://registry.npmjs.org/audio-type/-/audio-type-2.2.1.tgz" - integrity sha512-En9AY6EG1qYqEy5L/quryzbA4akBpJrnBZNxeKTqGHC2xT9Qc4aZ8b7CcbOMFTTc/MGdoNyp+SN4zInZNKxMYA== - -axios@^1.6.0: - version "1.7.5" - resolved "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz" - integrity sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw== - dependencies: - follow-redirects "^1.15.6" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - -boom@^7.3.0: - version "7.3.0" - resolved "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz" - integrity sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A== - dependencies: - hoek "6.x.x" - -browser-headers@^0.4.1: - version "0.4.1" - resolved "https://registry.npmjs.org/browser-headers/-/browser-headers-0.4.1.tgz" - integrity sha512-CA9hsySZVo9371qEHjHZtYxV2cFtVj5Wj/ZHi8ooEsrtm4vOnl9Y9HmyYWk9q+05d7K3rdoAE0j3MVEFVvtQtg== - -bson@^6.7.0: - version "6.8.0" - resolved "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz" - integrity sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ== - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-json@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/buffer-json/-/buffer-json-2.0.0.tgz" - integrity sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw== - -cac@^6.7.14: - version "6.7.14" - resolved "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz" - integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== - -cache-manager@4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/cache-manager/-/cache-manager-4.0.1.tgz" - integrity sha512-JWdtjdX8e0e6eMehAZsdJvBMvHn/pVQGYUjgzc1ILFH0vtcffb9R7XIEAqfYgEeaVJVCOSP4+dxCius+ciW0RA== - dependencies: - async "3.2.3" - lodash.clonedeep "^4.5.0" - lru-cache "^7.10.1" - -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz" - integrity sha512-8lgKz8LmCRYZZQDpRyT2m5rKJ08TnU4tR9FFFW2rxpxR1FzWi4PQ/NfyODchAatHaUgnSPVcx/R5w6NuTBzFiw== - dependencies: - restore-cursor "^2.0.0" - -cli-spinners@^2.0.0: - version "2.7.0" - resolved "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.7.0.tgz" - integrity sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw== - -clone@2.x: - version "2.1.2" - resolved "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz" - integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w== - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz" - integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== - -codec-parser@2.4.3: - version "2.4.3" - resolved "https://registry.npmjs.org/codec-parser/-/codec-parser-2.4.3.tgz" - integrity sha512-3dAvFtdpxn4YLstqsB2ZiJXXNg7n1j7R5ONeDuk+2kBkb39PwrCRytOFHlSWA8q5jCjW3PumeMv9q37bFHsijg== - -color-convert@^1.9.0: - version "1.9.3" - resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" - integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^9.4.0: - version "9.5.0" - resolved "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz" - integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== - -content-type@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz" - integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== - -curve25519-js@^0.0.4: - version "0.0.4" - resolved "https://registry.npmjs.org/curve25519-js/-/curve25519-js-0.0.4.tgz" - integrity sha512-axn2UMEnkhyDUPWOwVKBMVIzSQy2ejH2xRGy1wq81dqRwApXfIzfbE3hIX0ZRFBIihf/KDqK158DLwESu4AK1w== - -debug@^4.3.4: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -defaults@^1.0.3: - version "1.0.4" - resolved "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz" - integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== - dependencies: - clone "^1.0.2" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -dotenv@^16.0.2, dotenv@^16.0.3: - version "16.0.3" - resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz" - integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ== - -duplexify@^4.1.2: - version "4.1.3" - resolved "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz" - integrity sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA== - dependencies: - end-of-stream "^1.4.1" - inherits "^2.0.3" - readable-stream "^3.1.1" - stream-shift "^1.0.2" - -end-of-stream@^1.4.1: - version "1.4.4" - resolved "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -error-ex@^1.3.1: - version "1.3.2" - resolved "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -esbuild@^0.18.10: - version "0.18.20" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.18.20.tgz#4709f5a34801b43b799ab7d6d82f7284a9b7a7a6" - integrity sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA== - optionalDependencies: - "@esbuild/android-arm" "0.18.20" - "@esbuild/android-arm64" "0.18.20" - "@esbuild/android-x64" "0.18.20" - "@esbuild/darwin-arm64" "0.18.20" - "@esbuild/darwin-x64" "0.18.20" - "@esbuild/freebsd-arm64" "0.18.20" - "@esbuild/freebsd-x64" "0.18.20" - "@esbuild/linux-arm" "0.18.20" - "@esbuild/linux-arm64" "0.18.20" - "@esbuild/linux-ia32" "0.18.20" - "@esbuild/linux-loong64" "0.18.20" - "@esbuild/linux-mips64el" "0.18.20" - "@esbuild/linux-ppc64" "0.18.20" - "@esbuild/linux-riscv64" "0.18.20" - "@esbuild/linux-s390x" "0.18.20" - "@esbuild/linux-x64" "0.18.20" - "@esbuild/netbsd-x64" "0.18.20" - "@esbuild/openbsd-x64" "0.18.20" - "@esbuild/sunos-x64" "0.18.20" - "@esbuild/win32-arm64" "0.18.20" - "@esbuild/win32-ia32" "0.18.20" - "@esbuild/win32-x64" "0.18.20" - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - -fast-redact@^3.0.0: - version "3.5.0" - resolved "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz" - integrity sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A== - -file-type@^16.5.4: - version "16.5.4" - resolved "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz" - integrity sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw== - dependencies: - readable-web-to-node-stream "^3.0.0" - strtok3 "^6.2.4" - token-types "^4.1.1" - -find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -follow-redirects@^1.15.6: - version "1.15.6" - resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz" - integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== - -form-data-encoder@1.7.2: - version "1.7.2" - resolved "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz" - integrity sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A== - -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -formdata-node@^4.3.2: - version "4.4.1" - resolved "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz" - integrity sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ== - dependencies: - node-domexception "1.0.0" - web-streams-polyfill "4.0.0-beta.3" - -fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -futoin-hkdf@^1.5.1: - version "1.5.3" - resolved "https://registry.npmjs.org/futoin-hkdf/-/futoin-hkdf-1.5.3.tgz" - integrity sha512-SewY5KdMpaoCeh7jachEWFsh1nNlaDjNHZXWqL5IGwtpEYHTgkr2+AMCgNwKWkcc0wpSYrZfR7he4WdmHFtDxQ== - -google-protobuf@^3.21.0: - version "3.21.2" - resolved "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz" - integrity sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz" - integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/has/-/has-1.0.3.tgz" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -hoek@6.x.x: - version "6.1.3" - resolved "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz" - integrity sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ== - -hosted-git-info@^2.1.4: - version "2.8.9" - resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz" - integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== - -humanize-ms@^1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz" - integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== - dependencies: - ms "^2.0.0" - -ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inherits@^2.0.3: - version "2.0.4" - resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" - integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== - -is-core-module@^2.9.0: - version "2.11.0" - resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz" - integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== - dependencies: - has "^1.0.3" - -js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -json-parse-even-better-errors@^2.3.0: - version "2.3.1" - resolved "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -jsonc-parser@^3.2.0: - version "3.2.0" - resolved "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz" - integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w== - -libphonenumber-js@^1.10.20: - version "1.11.7" - resolved "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.11.7.tgz" - integrity sha512-x2xON4/Qg2bRIS11KIN9yCNYUjhtiEjNyptjX0mX+pyKHecxuJVLIpfX1lq9ZD6CrC/rB+y4GBi18c6CEcUR+A== - -"libsignal@github:WhiskeySockets/libsignal-node": - version "2.0.1" - resolved "git+ssh://git@github.com/WhiskeySockets/libsignal-node.git#83a3e3a3864511cb74df1b796373f0d49d071134" - dependencies: - curve25519-js "^0.0.4" - protobufjs "6.8.8" - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz" - integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== - -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log-symbols@^2.2.0: - version "2.2.0" - resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz" - integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== - dependencies: - chalk "^2.0.1" - -long@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -long@^5.0.0: - version "5.2.3" - resolved "https://registry.npmjs.org/long/-/long-5.2.3.tgz" - integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== - -lru-cache@^7.10.1: - version "7.18.3" - resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz" - integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== - -media-typer@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz" - integrity sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw== - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz" - integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== - -mimic-fn@^1.0.0: - version "1.2.0" - resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz" - integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== - -mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - -mlly@^1.1.0, mlly@^1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/mlly/-/mlly-1.1.1.tgz" - integrity sha512-Jnlh4W/aI4GySPo6+DyTN17Q75KKbLTyFK8BrGhjNP4rxuUjbRWhE6gHg3bs33URWAF44FRm7gdQA348i3XxRw== - dependencies: - acorn "^8.8.2" - pathe "^1.1.0" - pkg-types "^1.0.1" - ufo "^1.1.0" - -mongo-baileys@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/mongo-baileys/-/mongo-baileys-1.0.1.tgz" - integrity sha512-mKPhlci4oTmzARCvLDKUo2xtub0XlEE01UA9HS+42mMODd0SlSyA2NPNEn2HNkwadYvYLGunny1nydUgC0+FBA== - dependencies: - "@whiskeysockets/baileys" "*" - boom "^7.3.0" - buffer-json "^2.0.0" - mongodb "^6.8.0" - qrcode-terminal "^0.12.0" - -mongodb-connection-string-url@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.1.tgz" - integrity sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg== - dependencies: - "@types/whatwg-url" "^11.0.2" - whatwg-url "^13.0.0" - -mongodb@^6.8.0: - version "6.8.0" - resolved "https://registry.npmjs.org/mongodb/-/mongodb-6.8.0.tgz" - integrity sha512-HGQ9NWDle5WvwMnrvUxsFYPd3JEbqD3RgABHBQRuoCEND0qzhsd0iH5ypHsf1eJ+sXmvmyKpP+FLOKY8Il7jMw== - dependencies: - "@mongodb-js/saslprep" "^1.1.5" - bson "^6.7.0" - mongodb-connection-string-url "^3.0.0" - -mpg123-decoder@^0.4.10: - version "0.4.12" - resolved "https://registry.npmjs.org/mpg123-decoder/-/mpg123-decoder-0.4.12.tgz" - integrity sha512-BjeE7+D7FttqNRFtF3IgSSnG2Hn96ID4JDsCCmxhaPy2R1yuJu2gaabhlS9r12JibaRTT2SYDMXTyjD6xqe0fg== - dependencies: - "@wasm-audio-decoders/common" "9.0.4" - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.0.0: - version "2.1.3" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -music-metadata@^7.12.3: - version "7.14.0" - resolved "https://registry.npmjs.org/music-metadata/-/music-metadata-7.14.0.tgz" - integrity sha512-xrm3w7SV0Wk+OythZcSbaI8mcr/KHd0knJieu8bVpaPfMv/Agz5EooCAPz3OR5hbYMiUG6dgAPKZKnMzV+3amA== - dependencies: - "@tokenizer/token" "^0.3.0" - content-type "^1.0.5" - debug "^4.3.4" - file-type "^16.5.4" - media-typer "^1.1.0" - strtok3 "^6.3.0" - token-types "^4.2.1" - -nanoid@^3.3.7: - version "3.3.7" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" - integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== - -node-cache@^5.1.2: - version "5.1.2" - resolved "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz" - integrity sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg== - dependencies: - clone "2.x" - -node-domexception@1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz" - integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== - -node-fetch@^2.6.7: - version "2.7.0" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - -node-wav@^0.0.2: - version "0.0.2" - resolved "https://registry.npmjs.org/node-wav/-/node-wav-0.0.2.tgz" - integrity sha512-M6Rm/bbG6De/gKGxOpeOobx/dnGuP0dz40adqx38boqHhlWssBJZgLCPBNtb9NkrmnKYiV04xELq+R6PFOnoLA== - -normalize-package-data@^2.5.0: - version "2.5.0" - resolved "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz" - integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== - dependencies: - hosted-git-info "^2.1.4" - resolve "^1.10.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -ogg-opus-decoder@^1.6.8: - version "1.6.12" - resolved "https://registry.npmjs.org/ogg-opus-decoder/-/ogg-opus-decoder-1.6.12.tgz" - integrity sha512-6MY/rgFegJABKVE7LS10lmVoy8dFhvLDbIlcymgMnn0qZG0YHqcUU+bW+MkVyhhWN3H0vqtkRlPHGOXU6yR5YQ== - dependencies: - "@wasm-audio-decoders/common" "9.0.5" - codec-parser "2.4.3" - opus-decoder "0.7.6" - -on-exit-leak-free@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz" - integrity sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg== - -once@^1.4.0: - version "1.4.0" - resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz" - integrity sha512-oyyPpiMaKARvvcgip+JV+7zci5L8D1W9RZIz2l1o08AM3pfspitVWnPt3mzHcBPp12oYMTy0pqrFs/C+m3EwsQ== - dependencies: - mimic-fn "^1.0.0" - -openai@^4.56.0: - version "4.56.0" - resolved "https://registry.npmjs.org/openai/-/openai-4.56.0.tgz" - integrity sha512-zcag97+3bG890MNNa0DQD9dGmmTWL8unJdNkulZzWRXrl+QeD+YkBI4H58rJcwErxqGK6a0jVPZ4ReJjhDGcmw== - dependencies: - "@types/node" "^18.11.18" - "@types/node-fetch" "^2.6.4" - abort-controller "^3.0.0" - agentkeepalive "^4.2.1" - form-data-encoder "1.7.2" - formdata-node "^4.3.2" - node-fetch "^2.6.7" - -opus-decoder@0.7.6: - version "0.7.6" - resolved "https://registry.npmjs.org/opus-decoder/-/opus-decoder-0.7.6.tgz" - integrity sha512-5QYSl1YQYbSzWL7vM4dJoyrLC804xIvBFjfKTZZ6/z/EgmdFouOTT+8PDM2V18vzgnhRNPDuyB2aTfl/2hvMRA== - dependencies: - "@wasm-audio-decoders/common" "9.0.5" - -ora@3.2.0: - version "3.2.0" - resolved "https://registry.npmjs.org/ora/-/ora-3.2.0.tgz" - integrity sha512-XHMZA5WieCbtg+tu0uPF8CjvwQdNzKCX6BVh3N6GFsEXH40mTk5dsw/ya1lBTUGJslcEFJFQ8cBhOgkkZXQtMA== - dependencies: - chalk "^2.4.2" - cli-cursor "^2.1.0" - cli-spinners "^2.0.0" - log-symbols "^2.2.0" - strip-ansi "^5.0.0" - wcwidth "^1.0.1" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -parse-json@^5.0.0: - version "5.2.0" - resolved "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -pathe@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/pathe/-/pathe-1.1.0.tgz" - integrity sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w== - -peek-readable@^4.1.0: - version "4.1.0" - resolved "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz" - integrity sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg== - -picocolors@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" - integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== - -picocolors@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59" - integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw== - -pino-abstract-transport@v0.5.0: - version "0.5.0" - resolved "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz" - integrity sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ== - dependencies: - duplexify "^4.1.2" - split2 "^4.0.0" - -pino-std-serializers@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz" - integrity sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q== - -pino@^7.0.0: - version "7.11.0" - resolved "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz" - integrity sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg== - dependencies: - atomic-sleep "^1.0.0" - fast-redact "^3.0.0" - on-exit-leak-free "^0.2.0" - pino-abstract-transport v0.5.0 - pino-std-serializers "^4.0.0" - process-warning "^1.0.0" - quick-format-unescaped "^4.0.3" - real-require "^0.1.0" - safe-stable-stringify "^2.1.0" - sonic-boom "^2.2.1" - thread-stream "^0.15.1" - -pkg-types@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.2.tgz" - integrity sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ== - dependencies: - jsonc-parser "^3.2.0" - mlly "^1.1.1" - pathe "^1.1.0" - -postcss@^8.4.27: - version "8.4.47" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.47.tgz#5bf6c9a010f3e724c503bf03ef7947dcb0fea365" - integrity sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ== - dependencies: - nanoid "^3.3.7" - picocolors "^1.1.0" - source-map-js "^1.2.1" - -prettier@^2.8.4: - version "2.8.4" - resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz" - integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== - -process-warning@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz" - integrity sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q== - -protobufjs@6.8.8: - version "6.8.8" - resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz" - integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/long" "^4.0.0" - "@types/node" "^10.1.0" - long "^4.0.0" - -protobufjs@^7.2.4: - version "7.4.0" - resolved "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz" - integrity sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/node" ">=13.7.0" - long "^5.0.0" - -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - -punycode@^2.3.0: - version "2.3.1" - resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" - integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== - -qoa-format@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/qoa-format/-/qoa-format-1.0.1.tgz" - integrity sha512-dMB0Z6XQjdpz/Cw4Rf6RiBpQvUSPCfYlQMWvmuWlWkAT7nDQD29cVZ1SwDUB6DYJSitHENwbt90lqfI+7bvMcw== - dependencies: - "@thi.ng/bitstream" "^2.2.12" - -qrcode-terminal@^0.12.0: - version "0.12.0" - resolved "https://registry.npmjs.org/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz" - integrity sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ== - -quick-format-unescaped@^4.0.3: - version "4.0.4" - resolved "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz" - integrity sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg== - -read-pkg-up@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz" - integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg== - dependencies: - find-up "^4.1.0" - read-pkg "^5.2.0" - type-fest "^0.8.1" - -read-pkg@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz" - integrity sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg== - dependencies: - "@types/normalize-package-data" "^2.4.0" - normalize-package-data "^2.5.0" - parse-json "^5.0.0" - type-fest "^0.6.0" - -readable-stream@^3.1.1, readable-stream@^3.6.0: - version "3.6.2" - resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz" - integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readable-web-to-node-stream@^3.0.0: - version "3.0.2" - resolved "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.2.tgz" - integrity sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw== - dependencies: - readable-stream "^3.6.0" - -real-require@^0.1.0: - version "0.1.0" - resolved "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz" - integrity sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg== - -resolve@^1.10.0: - version "1.22.1" - resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz" - integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== - dependencies: - is-core-module "^2.9.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz" - integrity sha512-6IzJLuGi4+R14vwagDHX+JrXmPVtPpn4mffDJ1UdR7/Edm87fl6yi8mMBIVvFtJaNTUvjughmW4hwLhRG7gC1Q== - dependencies: - onetime "^2.0.0" - signal-exit "^3.0.2" - -rollup@^3.27.1: - version "3.29.5" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54" - integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w== - optionalDependencies: - fsevents "~2.3.2" - -rxjs@*: - version "7.8.1" - resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz" - integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== - dependencies: - tslib "^2.1.0" - -safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-stable-stringify@^2.1.0: - version "2.4.3" - resolved "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz" - integrity sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g== - -"semver@2 || 3 || 4 || 5": - version "5.7.1" - resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -signal-exit@^3.0.2: - version "3.0.7" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -simple-yenc@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/simple-yenc/-/simple-yenc-1.0.4.tgz" - integrity sha512-5gvxpSd79e9a3V4QDYUqnqxeD4HGlhCakVpb6gMnDD7lexJggSBJRBO5h52y/iJrdXRilX9UCuDaIJhSWm5OWw== - -sonic-boom@^2.2.1: - version "2.8.0" - resolved "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz" - integrity sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg== - dependencies: - atomic-sleep "^1.0.0" - -source-map-js@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" - integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== - -source-map-support@^0.5.21: - version "0.5.21" - resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz" - integrity sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ== - dependencies: - memory-pager "^1.0.2" - -spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== - dependencies: - spdx-expression-parse "^3.0.0" - spdx-license-ids "^3.0.0" - -spdx-exceptions@^2.1.0: - version "2.3.0" - resolved "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz" - integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== - -spdx-expression-parse@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz" - integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== - dependencies: - spdx-exceptions "^2.1.0" - spdx-license-ids "^3.0.0" - -spdx-license-ids@^3.0.0: - version "3.0.12" - resolved "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz" - integrity sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA== - -split2@^4.0.0: - version "4.2.0" - resolved "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz" - integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== - -stability-client@^1.8.0: - version "1.8.0" - resolved "https://registry.npmjs.org/stability-client/-/stability-client-1.8.0.tgz" - integrity sha512-zxNUTkBkicpBS4derFvDMQdouB3wdaKDhG+YL2+NHvoE+d1RDRqeKrDT5G+OlcmNQaefTZYhcX/myLTvG1oQzw== - dependencies: - "@improbable-eng/grpc-web" "^0.15.0" - "@improbable-eng/grpc-web-node-http-transport" "^0.15.0" - commander "^9.4.0" - dotenv "^16.0.2" - google-protobuf "^3.21.0" - mime "^3.0.0" - mkdirp "^1.0.4" - read-pkg-up "^7.0.1" - typed-emitter "^2.1.0" - uuid4 "^2.0.3" - -stream-shift@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz" - integrity sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ== - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -strip-ansi@^5.0.0: - version "5.2.0" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz" - integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== - dependencies: - ansi-regex "^4.1.0" - -strtok3@^6.2.4, strtok3@^6.3.0: - version "6.3.0" - resolved "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz" - integrity sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw== - dependencies: - "@tokenizer/token" "^0.3.0" - peek-readable "^4.1.0" - -supports-color@^5.3.0: - version "5.5.0" - resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -thread-stream@^0.15.1: - version "0.15.2" - resolved "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz" - integrity sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA== - dependencies: - real-require "^0.1.0" - -token-types@^4.1.1, token-types@^4.2.1: - version "4.2.1" - resolved "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz" - integrity sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ== - dependencies: - "@tokenizer/token" "^0.3.0" - ieee754 "^1.2.1" - -tr46@^4.1.1: - version "4.1.1" - resolved "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz" - integrity sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw== - dependencies: - punycode "^2.3.0" - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -tslib@^2.1.0: - version "2.5.0" - resolved "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz" - integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== - -type-fest@^0.6.0: - version "0.6.0" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz" - integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg== - -type-fest@^0.8.1: - version "0.8.1" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz" - integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== - -typed-emitter@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/typed-emitter/-/typed-emitter-2.1.0.tgz" - integrity sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA== - optionalDependencies: - rxjs "*" - -typescript@^4.9.5: - version "4.9.5" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== - -ufo@^1.1.0: - version "1.1.0" - resolved "https://registry.npmjs.org/ufo/-/ufo-1.1.0.tgz" - integrity sha512-LQc2s/ZDMaCN3QLpa+uzHUOQ7SdV0qgv3VBXOolQGXTaaZpIur6PwUclF5nN2hNkiTRcUugXd1zFOW3FLJ135Q== - -undici-types@~5.26.4: - version "5.26.5" - resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" - integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== - -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== - -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - -uuid4@^2.0.3: - version "2.0.3" - resolved "https://registry.npmjs.org/uuid4/-/uuid4-2.0.3.tgz" - integrity sha512-CTpAkEVXMNJl2ojgtpLXHgz23dh8z81u6/HEPiQFOvBc/c2pde6TVHmH4uwY0d/GLF3tb7+VDAj4+2eJaQSdZQ== - -uuid@^10.0.0: - version "10.0.0" - resolved "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz" - integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ== - -validate-npm-package-license@^3.0.1: - version "3.0.4" - resolved "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz" - integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -vite-node@^0.28.5: - version "0.28.5" - resolved "https://registry.npmjs.org/vite-node/-/vite-node-0.28.5.tgz" - integrity sha512-LmXb9saMGlrMZbXTvOveJKwMTBTNUH66c8rJnQ0ZPNX+myPEol64+szRzXtV5ORb0Hb/91yq+/D3oERoyAt6LA== - dependencies: - cac "^6.7.14" - debug "^4.3.4" - mlly "^1.1.0" - pathe "^1.1.0" - picocolors "^1.0.0" - source-map "^0.6.1" - source-map-support "^0.5.21" - vite "^3.0.0 || ^4.0.0" - -"vite@^3.0.0 || ^4.0.0": - version "4.5.5" - resolved "https://registry.yarnpkg.com/vite/-/vite-4.5.5.tgz#639b9feca5c0a3bfe3c60cb630ef28bf219d742e" - integrity sha512-ifW3Lb2sMdX+WU91s3R0FyQlAyLxOzCSCP37ujw0+r5POeHPwe6udWVIElKQq8gk3t7b8rkmvqC6IHBpCff4GQ== - dependencies: - esbuild "^0.18.10" - postcss "^8.4.27" - rollup "^3.27.1" - optionalDependencies: - fsevents "~2.3.2" - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz" - integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== - dependencies: - defaults "^1.0.3" - -web-streams-polyfill@4.0.0-beta.3: - version "4.0.0-beta.3" - resolved "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz" - integrity sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -webidl-conversions@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz" - integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== - -"whatsapp-ai-bot@file:.": - version "1.0.0" - dependencies: - "@google/generative-ai" "^0.17.1" - "@types/qrcode-terminal" "^0.12.0" - "@whiskeysockets/baileys" "^6.7.7" - dotenv "^16.0.3" - mongo-baileys "^1.0.1" - mongodb "^6.8.0" - openai "^4.56.0" - ora "3.2.0" - qrcode-terminal "^0.12.0" - stability-client "^1.8.0" - whatsapp-ai-bot "file:." - -whatwg-url@^13.0.0: - version "13.0.0" - resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz" - integrity sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig== - dependencies: - tr46 "^4.1.1" - webidl-conversions "^7.0.0" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -ws@^8.13.0: - version "8.18.0" - resolved "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz" - integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== From 78c3c0b34892f7143e4aa1fae031a704a872bb33 Mon Sep 17 00:00:00 2001 From: Vicente Date: Thu, 17 Oct 2024 11:13:28 -0300 Subject: [PATCH 09/12] commit --- .env.example | 29 ++- .gitignore | 1 + baileys/index.ts | 63 ------ .../index.d.ts => baileys/aimodeltype.d.ts} | 2 +- .../index.ts => baileys/database/mongo.ts} | 2 +- src/baileys/env.ts | 44 ++++ src/baileys/handlers/message.ts | 49 +++++ src/{lib => }/baileys/handlers/messages.ts | 0 .../baileys/hooks/useMessageParser.ts | 1 - src/{lib => }/baileys/index.ts | 49 ++++- src/index.ts | 2 +- src/lib/Queue.ts | 17 -- src/lib/WhatsAppClient.ts | 193 ------------------ src/lib/baileys/handlers/message.ts | 108 ---------- src/lib/env.ts | 12 -- src/lib/events/MessageEvent.ts | 28 --- src/models/AiModel.ts | 20 -- src/models/BaseAiModel.ts | 53 +++++ src/models/ChatGptModel.ts | 71 ------- src/models/CustomModel.ts | 108 ---------- src/models/DalleModel.ts | 8 +- src/models/FluxModel.ts | 4 +- src/models/GeminiModel.ts | 4 +- src/models/GeminiVisionModel.ts | 4 +- src/models/OpenAIModel.ts | 69 +++++++ src/models/StabilityModel.ts | 4 +- src/types/AiModels.d.ts | 5 +- src/types/Config.d.ts | 46 ++--- src/util/MessageTemplates.ts | 44 ++-- src/util/Util.ts | 4 +- src/whatsapp-ai.config.ts | 1 + 31 files changed, 348 insertions(+), 697 deletions(-) delete mode 100644 baileys/index.ts rename src/{lib/baileys/types/index.d.ts => baileys/aimodeltype.d.ts} (86%) rename src/{lib/mongo-db/index.ts => baileys/database/mongo.ts} (100%) create mode 100644 src/baileys/env.ts create mode 100644 src/baileys/handlers/message.ts rename src/{lib => }/baileys/handlers/messages.ts (100%) rename src/{lib => }/baileys/hooks/useMessageParser.ts (98%) rename src/{lib => }/baileys/index.ts (52%) delete mode 100644 src/lib/Queue.ts delete mode 100644 src/lib/WhatsAppClient.ts delete mode 100644 src/lib/baileys/handlers/message.ts delete mode 100644 src/lib/env.ts delete mode 100644 src/lib/events/MessageEvent.ts delete mode 100644 src/models/AiModel.ts create mode 100644 src/models/BaseAiModel.ts delete mode 100644 src/models/ChatGptModel.ts delete mode 100644 src/models/CustomModel.ts create mode 100644 src/models/OpenAIModel.ts diff --git a/.env.example b/.env.example index ae6bcd5..2195626 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,24 @@ -OPENAI_API_KEY=ADD_YOUR_KEY -DREAMSTUDIO_API_KEY=ADD_YOUR_KEY -GEMINI_API_KEY=ADD_YOUR_KEY -HF_TOKEN=HUGGING_FACE_TOKEN -MONGO_URL=YOUR_MONGO_DB_URL \ No newline at end of file +DEBUG=True + +# Model Services +API_KEY_OPENAI=ADD_YOUR_KEY +API_KEY_DREAMSTUDIO=ADD_YOUR_KEY +API_KEY_GEMINI=ADD_YOUR_KEY +API_KEY_HF=HUGGING_FACE_TOKEN + +# Optional +# API_KEY_OPENAI_DALLE=ADD_YOUR_KEY + +# MongoDB +MONGO_URL=YOUR_MONGO_DB_URL + + +# Service Settings +## OpenAI + +OPENAI_PREFIX=!chatgpt +OPENAI_ENABLED=True + +DALLE_PREFIX=!dalle +DALLE_ENABLED=True +DALLE_USE_3=False \ No newline at end of file diff --git a/.gitignore b/.gitignore index b4012d5..4e2cd6f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ package-lock.json +yarn.lock diff --git a/baileys/index.ts b/baileys/index.ts deleted file mode 100644 index 90d4ece..0000000 --- a/baileys/index.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Code for learning @whiskeysockets/baileys library - */ - -import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'; -import { Boom } from '@hapi/boom'; -import * as fs from 'fs'; - -const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys'); - -async function connectToWhatsApp() { - const sock = makeWASocket({ - // can provide additional config here - printQRInTerminal: true, - auth: state - }); - - sock.ev.on('connection.update', (update) => { - const { connection, lastDisconnect } = update; - try { - if (connection === 'close' && lastDisconnect) { - const shouldReconnect = - (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut; - - console.log( - 'connection closed due to ', - lastDisconnect.error, - ', reconnecting ', - shouldReconnect - ); - // reconnect if not logged out - if (shouldReconnect) { - connectToWhatsApp(); - } else { - // clear credentials - if (lastDisconnect.error) - fs.rmSync('./auth_info_baileys', { force: true, recursive: true }); - } - } else if (connection === 'open') { - console.log('opened connection'); - } - } catch (err) { - console.log(err); - } - }); - - sock.ev.on('messages.upsert', async (m) => { - console.log(JSON.stringify(m, undefined, 2)); - - console.log('replying to', m.messages[0].key.remoteJid); - // don't reply to self - if (m.messages[0].key.fromMe) { - console.log('returning this message is from me'); - return; - } - await sock.sendMessage(m.messages[0].key.remoteJid!, { text: 'Hello there!' }); - }); - - sock.ev.on('creds.update', saveCreds); -} - -// run in main file -connectToWhatsApp(); diff --git a/src/lib/baileys/types/index.d.ts b/src/baileys/aimodeltype.d.ts similarity index 86% rename from src/lib/baileys/types/index.d.ts rename to src/baileys/aimodeltype.d.ts index 8966d16..caa22c9 100644 --- a/src/lib/baileys/types/index.d.ts +++ b/src/baileys/aimodeltype.d.ts @@ -1,5 +1,5 @@ import makeWASocket, { MessageUpsertType, WAMessage } from '@whiskeysockets/baileys'; -import useMessageParser from '../hooks/useMessageParser'; +import useMessageParser from './hooks/useMessageParser'; type MessageHandlerParams = { client: ReturnType; diff --git a/src/lib/mongo-db/index.ts b/src/baileys/database/mongo.ts similarity index 100% rename from src/lib/mongo-db/index.ts rename to src/baileys/database/mongo.ts index b0848c2..6443376 100644 --- a/src/lib/mongo-db/index.ts +++ b/src/baileys/database/mongo.ts @@ -1,6 +1,6 @@ +import { AuthenticationCreds } from '@whiskeysockets/baileys'; import { MongoClient } from 'mongodb'; import { ENV } from '../env'; -import { AuthenticationCreds } from '@whiskeysockets/baileys'; interface AuthDocument extends Document { _id: string; diff --git a/src/baileys/env.ts b/src/baileys/env.ts new file mode 100644 index 0000000..66ddebe --- /dev/null +++ b/src/baileys/env.ts @@ -0,0 +1,44 @@ +import * as dotenv from 'dotenv'; +const configEnv = () => dotenv.config(); + +configEnv(); + +interface EnvInterface { + Debug: boolean; + + // Model Services + API_KEY_OPENAI: string | undefined; + API_KEY_OPENAI_DALLE: string | undefined; + API_KEY_DREAMSTUDIO: string | undefined; + API_KEY_GEMINI: string | undefined; + API_KEY_HF: string | undefined; + + // MongoDB + MONGO_URL: string | undefined; + + // Services + // // OpenAI + OPENAI_PREFIX: string | undefined; + OPENAI_ENABLED: boolean; + + DALLE_PREFIX: string | undefined; + DALLE_ENABLED: boolean; + DALLE_USE_3: boolean; +} + +export const ENV: EnvInterface = { + API_KEY_OPENAI: process.env.OPENAI_API_KEY, + API_KEY_OPENAI_DALLE: process.env.OPENAI_DALLE_API_KEY || process.env.OPENAI_API_KEY, + API_KEY_DREAMSTUDIO: process.env.DREAMSTUDIO_API_KEY, + API_KEY_GEMINI: process.env.GEMINI_API_KEY, + API_KEY_HF: process.env.HF_TOKEN, + MONGO_URL: process.env.MONGO_URL, + + Debug: process.env.DEBUG === 'True', + + OPENAI_PREFIX: process.env.OPENAI_PREFIX, + OPENAI_ENABLED: process.env.OPENAI_ENABLED === 'True', + DALLE_PREFIX: process.env.DALLE_PREFIX, + DALLE_ENABLED: process.env.DALLE_ENABLED === 'True', + DALLE_USE_3: process.env.DALLE_USE_3 === 'True' +}; diff --git a/src/baileys/handlers/message.ts b/src/baileys/handlers/message.ts new file mode 100644 index 0000000..a228c84 --- /dev/null +++ b/src/baileys/handlers/message.ts @@ -0,0 +1,49 @@ +/* Third-party modules */ +import { AnyMessageContent, downloadMediaMessage } from '@whiskeysockets/baileys'; + +/* Local modules */ +import MessageHandlerParams from './../aimodeltype'; +import { AiModels } from './../../types/AiModels'; +import { Util } from './../../util/Util'; + +/* Models */ +import { ChatGPTModel } from './../../models/OpenAIModel'; +import { GeminiModel } from './../../models/GeminiModel'; +import { FluxModel } from './../../models/FluxModel'; + +/* Declare models */ +const modelTable: Record = { + "ChatGPT": new ChatGPTModel(), + "Gemini": new GeminiModel(), + "FLUX": new FluxModel(), + Custom: undefined +}; + + +// handles message +export async function handleMessage({ client, msg, metadata }: MessageHandlerParams) { + const modelToUse = Util.getModelByPrefix(metadata.text) as AiModels; + if (!modelToUse) return; + + const prompt: string = metadata.text.split(' ').slice(1).join(' '); + + // handle models + const model = modelTable[modelToUse]; + if (!model) return; + + model.sendMessage({ sender: metadata.sender, prompt: prompt, metadata: metadata }, async (res: AnyMessageContent, err: any) => { + if ( err ) { + console.log(err); + return; + } + + client.sendMessage(metadata.remoteJid, res, { quoted: msg }); + }); +} + +// handles message from self +export async function handlerMessageFromMe({ metadata, client, msg, type }: MessageHandlerParams) { + if (metadata.fromMe && metadata.isQuoted) return; + if (metadata.isQuoted && Util.getModelByPrefix(metadata.text)) return; + await handleMessage({ metadata, client, msg, type }); +} diff --git a/src/lib/baileys/handlers/messages.ts b/src/baileys/handlers/messages.ts similarity index 100% rename from src/lib/baileys/handlers/messages.ts rename to src/baileys/handlers/messages.ts diff --git a/src/lib/baileys/hooks/useMessageParser.ts b/src/baileys/hooks/useMessageParser.ts similarity index 98% rename from src/lib/baileys/hooks/useMessageParser.ts rename to src/baileys/hooks/useMessageParser.ts index 560e73b..5c33163 100644 --- a/src/lib/baileys/hooks/useMessageParser.ts +++ b/src/baileys/hooks/useMessageParser.ts @@ -35,7 +35,6 @@ export default async function useMessageParser( | 'audio' = 'unknown'; if (conversation) msgType = 'text'; else if (extendedTextMessage) msgType = 'text'; - // msgType = 'extendedText'; else if (imageMessage) msgType = 'image'; else if (videoMessage) msgType = 'video'; else if (audioMessage) msgType = 'audio'; diff --git a/src/lib/baileys/index.ts b/src/baileys/index.ts similarity index 52% rename from src/lib/baileys/index.ts rename to src/baileys/index.ts index edc446f..b7743d9 100644 --- a/src/lib/baileys/index.ts +++ b/src/baileys/index.ts @@ -1,19 +1,42 @@ +/* Third-party modules */ import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@whiskeysockets/baileys'; +import { useMongoDBAuthState } from 'mongo-baileys'; import { Boom } from '@hapi/boom'; import * as fs from 'fs'; import path from 'path'; + + +/* Local modules */ import { messagesHandler } from './handlers/messages'; -import { useMongoDBAuthState } from 'mongo-baileys'; -import { ENV } from '../env'; -import { connectToMongoDB } from '../mongo-db'; +import { connectToMongoDB } from './database/mongo'; +import { ENV } from './env'; + + +/* Util */ +const connectToDatabase = async () => { + const UseMongoDB: boolean = ENV.MONGO_URL !== undefined; + if (UseMongoDB) { + return await useMongoDBAuthState( + ( await connectToMongoDB() ).collection as any + ); + } else { + return await useMultiFileAuthState('auth_info_baileys'); + } +} + +const credentialsDirPath: string = path.join(process.cwd(), './auth_info_baileys'); + + +/* Connect to WhatsApp */ export async function connectToWhatsApp() { - const { state, saveCreds } = - ENV.MONGO_URL !== undefined - ? await useMongoDBAuthState((await connectToMongoDB()).collection as any) - : await useMultiFileAuthState('auth_info_baileys'); + // Determine the authentication state based on the environment configuration + const { state, saveCreds } = await connectToDatabase(); + + // Create a new WhatsApp socket connection const sock = makeWASocket({ printQRInTerminal: true, auth: state }); + // Handle connection updates sock.ev.on('connection.update', async (update) => { const { connection, lastDisconnect } = update; @@ -21,23 +44,27 @@ export async function connectToWhatsApp() { if (connection === 'close' && lastDisconnect) { const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut; + if (shouldReconnect) { connectToWhatsApp(); } else { - const credentialsDirPath = path.join(process.cwd(), './auth_info_baileys'); if (lastDisconnect.error) { fs.rmSync(credentialsDirPath, { force: true, recursive: true }); connectToWhatsApp(); } } - } else if (connection == 'open') { - // here we go + } else if (connection === 'open') { + // Connection is open } - } catch (err) {} + } catch (err) { + console.error('Error handling connection update:', err); + } }); + // Handle credential updates sock.ev.on('creds.update', saveCreds); + // Handle incoming messages sock.ev.on('messages.upsert', (args) => { messagesHandler({ client: sock, ...args }); }); diff --git a/src/index.ts b/src/index.ts index 49b780b..f57cbc6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,5 +7,5 @@ // whatsappClient.messageEvent.on('self', welcomeUser); -import { connectToWhatsApp } from './lib/baileys'; +import { connectToWhatsApp } from "./baileys"; connectToWhatsApp(); diff --git a/src/lib/Queue.ts b/src/lib/Queue.ts deleted file mode 100644 index 630bccd..0000000 --- a/src/lib/Queue.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Message } from 'whatsapp-web.js'; - -class Queue { - public constructor() { - this.list = []; - } - - public Enqueue(msg: Message) { - this.list.push(msg); - } - - public Dequeue() {} - - private list: Array; -} - -export { Queue }; diff --git a/src/lib/WhatsAppClient.ts b/src/lib/WhatsAppClient.ts deleted file mode 100644 index 613aff7..0000000 --- a/src/lib/WhatsAppClient.ts +++ /dev/null @@ -1,193 +0,0 @@ -// whatsapp client -import { Client, Message, LocalAuth, AuthStrategy, NoAuth } from 'whatsapp-web.js'; -import QRCode from 'qrcode-terminal'; - -// config file -import config from '../whatsapp-ai.config'; - -// base typess -import { AiModels } from '../types/AiModels'; -import { AiModel } from '../models/AiModel'; - -// extends from base -import { ChatGptModel } from '../models/ChatGptModel'; -import { StabilityModel } from '../models/StabilityModel'; -import { DalleModel } from '../models/DalleModel'; -import { CustomModel } from '../models/CustomModel'; -import { GeminiModel } from '../models/GeminiModel'; - -// utilities -import { Util } from '../util/Util'; - -// hooks -import { useSpinner } from '../hooks/useSpinner'; -import { IModelConfig } from '../types/Config'; -import { GeminiVisionModel } from '../models/GeminiVisionModel'; -import MessageEvent from './events/MessageEvent'; - -class WhatsAppClient { - public constructor() { - const wwebVersion = '2.2412.54'; - - const sessionStorage: AuthStrategy = config.sessionStorage.enable - ? new LocalAuth({ - dataPath: config.sessionStorage.wwjsPath - }) - : new NoAuth(); - - this.client = new Client({ - puppeteer: { - args: ['--no-sandbox'] - }, - authStrategy: sessionStorage, - webVersionCache: { - type: 'remote', - remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${wwebVersion}.html` - } - }); - - this.aiModels = new Map>(); - - // init models - this.aiModels.set('ChatGPT', new ChatGptModel()); - this.aiModels.set('DALLE', new DalleModel()); - this.aiModels.set('StableDiffusion', new StabilityModel()); - this.aiModels.set('Gemini', new GeminiModel()); - this.aiModels.set('GeminiVision', new GeminiVisionModel()); - - this.customModel = new CustomModel(); - - // events - this.messageEvent = new MessageEvent(); - } - - public initializeClient() { - this.subscribeEvents(); - this.client.initialize(); - } - - private subscribeEvents() { - const spinner = useSpinner('Whats App Client | Starting... \n'); - spinner.start(); - this.client - .on('qr', (qr) => { - WhatsAppClient.generateQrCode(qr); - spinner.succeed(`QR has been generated! | Scan QR Code with you're mobile.`); - }) - .on('auth_failure', (message) => spinner.fail(`Authentication fail ${message}`)) - .on('authenticated', () => spinner.succeed('User Authenticated!')) - .on('loading_screen', () => spinner.start('loading chat... \n')) - .on('ready', () => spinner.succeed('Client is ready | All set!')) - // arrow function to prevent this binding - .on('message', async (msg) => this.onMessage(msg)) - .on('message_create', async (msg) => this.onSelfMessage(msg)); - } - - private static generateQrCode(qr: string) { - QRCode.generate(qr, { small: true }); - } - - private async onMessage(message: Message) { - const msgStr = message.body; - - if (msgStr.length == 0) return; - - // emit events - this.messageEvent.emit(message.fromMe ? 'self' : 'incoming', message, this); - - const modelToUse = Util.getModelByPrefix(msgStr) as AiModels; - - // media - if (message.hasMedia) { - if (modelToUse === undefined || this.aiModels.get(modelToUse)?.modelType !== 'Image') - return; - - const model: IModelConfig = config.models[modelToUse] as IModelConfig; - - this.aiModels.get(modelToUse)?.sendMessage(msgStr.replace(model.prefix, ''), message); - - return; - } - - const messageToSelf = - message.fromMe && message.hasQuotedMsg === false && message.from === message.to; - - // message to self without prefix - if (modelToUse == undefined && messageToSelf && config.selfMessage.skipPrefix) { - this.sendMessage(msgStr, message, config.enablePrefix.defaultModel); - return; - } - - // message without prefix - if (modelToUse == undefined && !config.enablePrefix.enable) { - this.sendMessage(msgStr, message, config.enablePrefix.defaultModel); - return; - } - - if (modelToUse == undefined) return; // no models added - - // message with prefix - if (this.aiModels.get(modelToUse)) { - const model: IModelConfig = config.models[modelToUse] as IModelConfig; - this.aiModels.get(modelToUse)?.sendMessage(msgStr.replace(model.prefix, ''), message); - } else { - // use custom model - this.customModel.sendMessage( - { - prompt: msgStr, - modelName: modelToUse, - resolve: async (model, contextPrompt) => { - this.aiModels.get(model)?.sendMessage(contextPrompt, message); - } - }, - message - ); - } - } - - private async onSelfMessage(message: Message) { - if (!message.fromMe) return; - if (message.hasQuotedMsg && !Util.getModelByPrefix(message.body)) return; - this.onMessage(message); - } - - public async sendMessage(msgStr: string, message: Message, modelName: string) { - if (this.aiModels.get(modelName as AiModels)) { - const model: IModelConfig = config.models[modelName as AiModels] as IModelConfig; - this.aiModels - .get(modelName as AiModels) - ?.sendMessage(msgStr.replace(model.prefix, ''), message); - } else { - this.customModel.sendMessage( - { - prompt: msgStr, - modelName, - resolve: async (model, contextPrompt) => { - this.aiModels.get(model)?.sendMessage(contextPrompt, message); - } - }, - message - ); - } - } - - public self() { - return this.client; - } - - private client; - - // models require prompt to generate output - private aiModels: Map>; - private customModel: CustomModel; - - // events - public messageEvent: MessageEvent; - - // Helper functions -} - -export { WhatsAppClient }; - -// DOCS: -// https://wwebjs.dev/guide/#qr-code-generation diff --git a/src/lib/baileys/handlers/message.ts b/src/lib/baileys/handlers/message.ts deleted file mode 100644 index 79f58f0..0000000 --- a/src/lib/baileys/handlers/message.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { downloadMediaMessage } from '@whiskeysockets/baileys'; -import { ChatGptModel } from '../../../models/ChatGptModel'; -import { GeminiModel } from '../../../models/GeminiModel'; -import { GeminiVisionModel } from '../../../models/GeminiVisionModel'; -import { AiModels } from '../../../types/AiModels'; -import { Util } from '../../../util/Util'; -import MessageHandlerParams from '../types'; -import { DalleModel } from '../../../models/DalleModel'; -import { FluxModel } from '../../../models/FluxModel'; - -const gptModel = new ChatGptModel(); -const geminiModel = new GeminiModel(); -const geminiVisionModel = new GeminiVisionModel(); -const dalle2Model = new DalleModel('DALLE'); -const dalle3Model = new DalleModel('DALLE3'); -const fluxModel = new FluxModel(); - -// handles message -export async function handleMessage({ client, msg, metadata }: MessageHandlerParams) { - const modelToUse = Util.getModelByPrefix(metadata.text) as AiModels; - - if (!modelToUse) return; - - const prompt = metadata.text.split(' ').slice(1).join(' '); - - if (modelToUse === 'ChatGPT' && metadata.msgType === 'text') { - await gptModel.sendMessage({ sender: metadata.sender, prompt }, async (res, err) => { - client.sendMessage(metadata.remoteJid, { text: err || res }, { quoted: msg }); - }); - return; - } - - if (modelToUse === 'Gemini' && metadata.msgType === 'text') { - await geminiModel.sendMessage({ sender: metadata.sender, prompt }, async (res, err) => { - client.sendMessage(metadata.remoteJid, { text: err || res }, { quoted: msg }); - }); - return; - } - - if (modelToUse === 'DALLE' && metadata.msgType === 'text') { - await dalle2Model.sendMessage({ sender: metadata.sender, prompt }, async (res, err) => { - if (!err) { - await client.sendMessage( - metadata.remoteJid, - { image: { url: res.url }, caption: res.caption }, - { quoted: msg } - ); - } else { - await client.sendMessage(metadata.remoteJid, { text: err }, { quoted: msg }); - } - }); - return; - } - - if (modelToUse === 'DALLE3' && metadata.msgType === 'text') { - await dalle3Model.sendMessage({ sender: metadata.sender, prompt }, async (res, err) => { - if (!err) { - await client.sendMessage( - metadata.remoteJid, - { image: { url: res.url }, caption: res.caption }, - { quoted: msg } - ); - } else { - await client.sendMessage(metadata.remoteJid, { text: err }, { quoted: msg }); - } - }); - return; - } - - if (modelToUse === 'FLUX' && metadata.msgType === 'text') { - await fluxModel.sendMessage({ sender: metadata.sender, prompt }, async (res, err) => { - if (!err) { - client.sendMessage(metadata.remoteJid, { image: res }, { quoted: msg }); - } else { - client.sendMessage(metadata.remoteJid, { text: err }, { quoted: msg }); - } - }); - return; - } - - // Generative Models - if ( - modelToUse === 'GeminiVision' && - metadata.msgType === 'image' && - metadata.imgMetaData.caption - ) { - const { mimeType, url } = metadata.imgMetaData; - if (mimeType === 'image/jpeg') { - const buffer = await downloadMediaMessage(msg, 'buffer', {}); - await geminiVisionModel.sendMessage( - { sender: metadata.sender, prompt: { prompt, buffer, mimeType } }, - async (res, err) => { - client.sendMessage(metadata.remoteJid, { text: err || res }, { quoted: msg }); - } - ); - return; - } - } - - client.sendMessage(metadata.remoteJid, { text: `Hi It's WAAI BOT here 🤖` }, { quoted: msg }); -} - -// handles message from self -export async function handlerMessageFromMe({ metadata, client, msg, type }: MessageHandlerParams) { - if (metadata.fromMe && metadata.isQuoted) return; - if (metadata.isQuoted && Util.getModelByPrefix(metadata.text)) return; - await handleMessage({ metadata, client, msg, type }); -} diff --git a/src/lib/env.ts b/src/lib/env.ts deleted file mode 100644 index 03524d8..0000000 --- a/src/lib/env.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as dotenv from 'dotenv'; -const configEnv = () => dotenv.config(); - -configEnv(); - -export const ENV = { - openAIKey: process.env.OPENAI_API_KEY, - dreamStudioKey: process.env.DREAMSTUDIO_API_KEY, - geminiKey: process.env.GEMINI_API_KEY, - HFKey: process.env.HF_TOKEN, - MONGO_URL: process.env.MONGO_URL -}; diff --git a/src/lib/events/MessageEvent.ts b/src/lib/events/MessageEvent.ts deleted file mode 100644 index 1ccfede..0000000 --- a/src/lib/events/MessageEvent.ts +++ /dev/null @@ -1,28 +0,0 @@ -import EventEmitter from 'events'; -import { Message } from 'whatsapp-web.js'; -import { WhatsAppClient } from '../WhatsAppClient'; - -/** - * There are two types of messages: - * * self - messages sent by the user currently using the bot. - * * incoming - messages received from other users to the bot user. - */ -type MessageType = 'self' | 'incoming'; - -export default class MessageEvent { - public constructor() { - this.onMessageEvents = new Map(); - this.onMessageEvents.set('self', new EventEmitter()); - this.onMessageEvents.set('incoming', new EventEmitter()); - } - - public emit(messageType: MessageType, message: Message, client: WhatsAppClient) { - this.onMessageEvents.get(messageType)?.emit(messageType, message, client); - } - - public on(messageType: MessageType, callBack: (msg: Message, client: WhatsAppClient) => void) { - this.onMessageEvents.get(messageType)?.addListener(messageType, callBack); - } - - private onMessageEvents: Map; -} diff --git a/src/models/AiModel.ts b/src/models/AiModel.ts deleted file mode 100644 index ee1f373..0000000 --- a/src/models/AiModel.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { AiModels } from '../types/AiModels'; - -type ModelType = 'Text' | 'Image'; - -/// base class for all AI models -abstract class AiModel { - public constructor(apiKey: string | undefined, aiModelName: AiModels, modelType?: ModelType) { - this.apiKey = apiKey || 'undefined'; - this.aiModelName = aiModelName; - this.modelType = modelType || 'Text'; - } - - abstract sendMessage(args: Arguments, handle: CallBack): Promise; - - public apiKey: string; - public aiModelName: AiModels; - public modelType: ModelType; -} - -export { AiModel }; diff --git a/src/models/BaseAiModel.ts b/src/models/BaseAiModel.ts new file mode 100644 index 0000000..3962451 --- /dev/null +++ b/src/models/BaseAiModel.ts @@ -0,0 +1,53 @@ +import { MessageUpsertType } from '@whiskeysockets/baileys'; +import { AiModels } from '../types/AiModels'; + +type MetaData = { + remoteJid: string; + sender: string; + senderName?: string; + fromMe: boolean; + msgType: 'unknown' | 'text' | 'extendedText' | 'image' | 'video' | 'document' | 'contact' | 'location' | 'audio'; + type: MessageUpsertType; + isQuoted: boolean; + timeStamp: Date; + text: string; + isGroup: boolean; + groupMetaData: { + groupName: string; + groupIsLocked: boolean; + }; + imgMetaData: { + url: string; + mimeType: string; + caption: string; + }; + audioMetaData: { + url: string; + mimeType: string; + }; +}; + +interface AIArguments { + sender: string; + prompt: string; + metadata: MetaData; + prefix: string; +} + +abstract class AiModel { + /* Variables */ + private apiKey: string; + public modelName: AiModels; + + /* Methods */ + public constructor(apiKey: string | undefined, aiModelName: AiModels) { + this.apiKey = apiKey || 'undefined'; + this.modelName = aiModelName; + } + + public getApiKey(): string { return this.apiKey; } + + abstract sendMessage(args: AIArguments, handle: CallBack): Promise; +} + +export { AiModel, AIArguments }; diff --git a/src/models/ChatGptModel.ts b/src/models/ChatGptModel.ts deleted file mode 100644 index 6bd2cab..0000000 --- a/src/models/ChatGptModel.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { AiModel } from './AiModel'; -import { useSpinner } from '../hooks/useSpinner'; -import { MessageTemplates } from '../util/MessageTemplates'; - -import { ENV } from '../lib/env'; -import config from '../whatsapp-ai.config'; -import OpenAI from 'openai'; -import { ChatCompletionMessageParam } from 'openai/resources/chat/completions'; - -interface ChatGptModelParams { - sender: string; - prompt: string; -} - -type HandleType = (res: string, error?: string) => Promise; - -class ChatGptModel extends AiModel { - public constructor() { - super(ENV.openAIKey, 'ChatGPT'); - this.openai = new OpenAI({ - apiKey: this.apiKey - }); - - this.history = {}; - } - - public async sendMessage( - { prompt, sender }: ChatGptModelParams, - handle: HandleType - ): Promise { - const spinner = useSpinner(MessageTemplates.requestStr(this.aiModelName, sender, prompt)); - spinner.start(); - try { - const startTime = Date.now(); - - if (this.history[sender] === undefined) this.history[sender] = []; - this.history[sender].push({ role: 'user', content: prompt }); - - const completion = await this.openai.chat.completions.create({ - messages: this.history[sender], - model: config.chatGPTModel - }); - - // TODO: Get Total tokens, Get finish reason - - const message = completion.choices[0].message; - this.history[sender].push(message); - - const res = message.content || ''; - await handle(res); - - spinner.succeed( - MessageTemplates.reqSucceedStr(this.aiModelName, sender, res, Date.now() - startTime) - ); - } catch (err) { - spinner.fail( - MessageTemplates.reqFailStr( - this.aiModelName, - 'at ChatGptModel.ts sendMessage(prompt, msg)', - err - ) - ); - await handle('', 'An error occur please see console for more information.'); - } - } - - private history: { [from: string]: ChatCompletionMessageParam[] }; - private openai: OpenAI; -} - -export { ChatGptModel }; diff --git a/src/models/CustomModel.ts b/src/models/CustomModel.ts deleted file mode 100644 index 184df63..0000000 --- a/src/models/CustomModel.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { AiModel } from './AiModel'; -import type { Message } from 'whatsapp-web.js'; -import { useSpinner } from '../hooks/useSpinner'; -import { MessageTemplates } from '../util/MessageTemplates'; - -// config file -import config from '../whatsapp-ai.config'; -import { IModelType } from '../types/Config'; - -import fetch from 'node-fetch'; -import { readFile } from 'fs/promises'; -import { AiModelsName } from '../types/AiModels'; - -export type CustomModelProps = { - prompt: string; modelName: string, - resolve: (model: AiModelsName, prompt: string)=> Promise -}; - -class CustomModel extends AiModel { - public constructor() { - super('', 'Custom') - } - - public async sendMessage({ prompt, modelName, resolve }: CustomModelProps, msg: Message): Promise { - const spinner = useSpinner(MessageTemplates.requestStr(this.aiModelName, msg.from, prompt)); - - try { - const customModel = CustomModel.getCustomModel(modelName); - - if (!customModel) return; - - let sender = '' - if (customModel.includeSender) - { - const chat = await msg.getChat(); - sender = `sender: ${chat.name}`; - } - - const contextPrompt = CustomModel.createContext( - await CustomModel.readContext(customModel), - prompt.replace(customModel.prefix, ''), - sender - ); - - resolve(customModel.modelToUse || 'Gemini', contextPrompt); - - } catch (err) { - spinner.fail( - MessageTemplates.reqFailStr( - this.aiModelName, - 'at CustomModel.ts sendMessage(prompt, msg)', - err - ) - ); - msg.reply('An error occur please see console for more information.'); - } - } - - private static createContext(context: string, prompt: string, sender: string = '') { - return ` - ${sender} - context: - ${context} - note! - only answer from the given context - question: - ${prompt} - `; - } - - private static getCustomModel(modelName: string): IModelType | undefined { - if (!config.models.Custom) return undefined; - for (let model of config.models.Custom) if (model.modelName == modelName) return model; - return config.models.Custom[0]; - } - - private static async readContext(model: IModelType) { - const supportedFiles = ['.txt', '.text', '.md']; - const httpProtocols = [ - 'https://', - 'http://', - 'ftp://', - 'ftps://', - 'sftp://', - 'ssh://', - 'git://', - 'svn://', - 'ws://', - 'wss://' - ]; - - if ( - httpProtocols.filter((protocol) => model.context.trim().startsWith(protocol)).length > 0 - ) { - const res = await fetch(model.context); - return res.text(); - } - - if (supportedFiles.filter((fileExt) => model.context.trim().endsWith(fileExt)).length > 0) { - return readFile(model.context, { encoding: 'utf-8' }); - } - - // plane text - return model.context; - } -} - -export { CustomModel }; diff --git a/src/models/DalleModel.ts b/src/models/DalleModel.ts index dbb3cc6..914cb09 100644 --- a/src/models/DalleModel.ts +++ b/src/models/DalleModel.ts @@ -1,9 +1,9 @@ -import { AiModel } from './AiModel'; +import { AiModel } from './BaseAiModel'; import { useSpinner } from '../hooks/useSpinner'; import OpenAI from 'openai'; import { MessageTemplates } from '../util/MessageTemplates'; -import { ENV } from '../lib/env'; +import { ENV } from '../baileys/env'; interface DalleModelParams { sender: string; @@ -17,8 +17,8 @@ type HandleType = ( class DalleModel extends AiModel { public constructor(modelName: 'DALLE' | 'DALLE3') { - super(ENV.openAIKey, modelName); - this.client = new OpenAI({ apiKey: this.apiKey }); + super(ENV.API_KEY_OPENAI, modelName); + this.client = new OpenAI({ apiKey: this.getApiKey() }); } public async sendMessage( diff --git a/src/models/FluxModel.ts b/src/models/FluxModel.ts index 0dd55e1..d0772fd 100644 --- a/src/models/FluxModel.ts +++ b/src/models/FluxModel.ts @@ -1,7 +1,7 @@ import { useSpinner } from '../hooks/useSpinner'; -import { ENV } from '../lib/env'; +import { ENV } from '../baileys/env'; import { MessageTemplates } from '../util/MessageTemplates'; -import { AiModel } from './AiModel'; +import { AiModel } from './BaseAiModel'; interface FluxAiModelParams { sender: string; diff --git a/src/models/GeminiModel.ts b/src/models/GeminiModel.ts index f1ac6af..3ffb771 100644 --- a/src/models/GeminiModel.ts +++ b/src/models/GeminiModel.ts @@ -1,5 +1,5 @@ -import { AiModel } from './AiModel'; -import { ENV } from '../lib/env'; +import { AiModel } from './BaseAiModel'; +import { ENV } from '../baileys/env'; import { useSpinner } from '../hooks/useSpinner'; import { MessageTemplates } from '../util/MessageTemplates'; import { Content, GoogleGenerativeAI } from '@google/generative-ai'; diff --git a/src/models/GeminiVisionModel.ts b/src/models/GeminiVisionModel.ts index c65b97b..025fb4f 100644 --- a/src/models/GeminiVisionModel.ts +++ b/src/models/GeminiVisionModel.ts @@ -1,5 +1,5 @@ -import { AiModel } from './AiModel'; -import { ENV } from '../lib/env'; +import { AiModel } from './BaseAiModel'; +import { ENV } from '../baileys/env'; import { GoogleGenerativeAI } from '@google/generative-ai'; import { useSpinner } from '../hooks/useSpinner'; import { MessageTemplates } from '../util/MessageTemplates'; diff --git a/src/models/OpenAIModel.ts b/src/models/OpenAIModel.ts new file mode 100644 index 0000000..815a029 --- /dev/null +++ b/src/models/OpenAIModel.ts @@ -0,0 +1,69 @@ +/* Third-party modules */ +import { ChatCompletionMessageParam, ChatCompletionMessage } from 'openai/resources/chat/completions'; +import OpenAI from 'openai'; + +/* Local modules */ +import { AiModel, AIArguments } from './BaseAiModel'; +import { ENV } from '../baileys/env'; +import config from '../whatsapp-ai.config'; + +type HandleType = (res: string, error?: string) => Promise; + +class ChatGPTModel extends AiModel { + private history: { [from: string]: ChatCompletionMessageParam[] }; + private Dalle3: boolean; + private Dalle: OpenAI; + private OpenAI: OpenAI; + + public constructor() { + super(ENV.API_KEY_OPENAI, 'ChatGPT'); + + this.OpenAI = new OpenAI({ + apiKey: this.getApiKey() + }); + + this.Dalle = new OpenAI({ + apiKey: ENV.API_KEY_OPENAI_DALLE + }); + + this.history = {}; + this.Dalle3 = ENV.DALLE_USE_3; + } + + public sessionCreate(user: string): void { this.history[user] = [] }; + public sessionExists(user: string): boolean { return this.history[user] !== undefined }; + public sessionAddMessage(user: string, args: any): void { this.history[user].push(args) }; + + public async generateCompletion(user: string): Promise { + const completion = await this.OpenAI.chat.completions.create({ + messages: this.history[user], + model: config.chatGPTModel + }); + + const message = completion.choices[0].message; + this.history[user].push(message); + + return message; + } + + public async generateImage() { + + } + + public async sendMessage({ sender, prompt }: AIArguments, handle: HandleType): Promise { + try { + if ( !this.sessionExists(sender) ) { this.sessionCreate(sender) }; + + this.sessionAddMessage(sender, { role: 'user', content: prompt }); + + const completion = await this.generateCompletion(sender); + + const res = completion.content || ''; + await handle(res); + } catch (err) { + await handle('', 'An error occur please see console for more information.'); + } + } +} + +export { ChatGPTModel }; \ No newline at end of file diff --git a/src/models/StabilityModel.ts b/src/models/StabilityModel.ts index 0e9d529..6fb8d41 100644 --- a/src/models/StabilityModel.ts +++ b/src/models/StabilityModel.ts @@ -1,10 +1,10 @@ -import { AiModel } from './AiModel'; +import { AiModel } from './BaseAiModel'; import fetch from 'node-fetch'; import { useSpinner } from '../hooks/useSpinner'; import type { Message } from 'whatsapp-web.js'; import { MessageMedia } from 'whatsapp-web.js'; import { MessageTemplates } from '../util/MessageTemplates'; -import { ENV } from '../lib/env'; +import { ENV } from '../baileys/env'; class StabilityModel extends AiModel { public constructor() { diff --git a/src/types/AiModels.d.ts b/src/types/AiModels.d.ts index e799b0e..b624a7d 100644 --- a/src/types/AiModels.d.ts +++ b/src/types/AiModels.d.ts @@ -1,10 +1,7 @@ export type AiModels = | 'ChatGPT' - | 'DALLE' - | 'StableDiffusion' | 'Gemini' - | 'GeminiVision' | 'Custom' - | 'DALLE3' | 'FLUX'; + export type AiModelsName = Exclude; diff --git a/src/types/Config.d.ts b/src/types/Config.d.ts index 3964d9b..42ebd24 100644 --- a/src/types/Config.d.ts +++ b/src/types/Config.d.ts @@ -1,37 +1,37 @@ import { AiModels, AiModelsName } from './AiModels'; export interface IModelConfig { - prefix: string; - enable?: boolean; + prefix: string; + enable?: boolean; } export interface IModelType extends IModelConfig { - modelName: string; - prefix: string; - context: string; - modelToUse?: AiModelsName; - includeSender?: boolean; + modelName: string; + prefix: string; + context: string; + modelToUse?: AiModelsName; + includeSender?: boolean; } export interface IDefaultConfig { - enable?: boolean; - /** default model to use when prefix is disabled*/ - defaultModel: AiModels; + enable?: boolean; + /** default model to use when prefix is disabled*/ + defaultModel: AiModels; } export type Config = { - models: { - [key in AiModels]?: key extends 'Custom' ? Array | [] : IModelConfig | null; - }; + models: { + [key in AiModels]?: key extends 'Custom' ? Array | [] : IModelConfig | null; + }; } & { - enablePrefix: IDefaultConfig; - sessionStorage: { - enable: boolean; - wwjsPath: string; - }; - chatGPTModel: string; - sendWelcomeMessage: boolean; - selfMessage: { - skipPrefix: boolean; - }; + enablePrefix: IDefaultConfig; + sessionStorage: { + enable: boolean; + wwjsPath: string; + }; + chatGPTModel: string; + sendWelcomeMessage: boolean; + selfMessage: { + skipPrefix: boolean; + }; }; diff --git a/src/util/MessageTemplates.ts b/src/util/MessageTemplates.ts index f521cfb..d4ff19f 100644 --- a/src/util/MessageTemplates.ts +++ b/src/util/MessageTemplates.ts @@ -1,20 +1,32 @@ -class MessageTemplates { - public static requestStr(model: string, from: string, prompt: string): string { - return `${model}Model fetching | prompt:"${prompt}" from user:"${from}"\n`; - } +import { ENV } from '../baileys/env'; - public static reqSucceedStr( - model: string, - from: string, - response: string, - timeTook: number - ): string { - return `${model}Model succeed | reply has been sent to user:"${from}" response:${response} \n\n`; - } +type MessageType = 'fetch' | 'succeed' | 'failed'; - public static reqFailStr(model: string, errInfo: string, err: any) { - return `${model}Model request fail | An error occur, ${errInfo} err: ${err}\n`; - } +interface MessageTemplate { + model: string; + from: string; + prompt: string; + type: MessageType; + response?: string; + timeTook?: number; + errInfo?: string; + err?: any; } -export { MessageTemplates }; +export default function generateMessage( + type: MessageType, + template: MessageTemplate +): string | undefined { + if (ENV.Debug === false) return; + + switch (type) { + case 'fetch': + return `${template.model}Model fetching | prompt:"${template.prompt}" from user:"${template.from}"\n`; + case 'succeed': + return `${template.model}Model succeed | reply has been sent to user:"${template.from}" response:${template.response} \n\n`; + case 'failed': + return `${template.model}Model request fail | An error occur, ${template.errInfo} err: ${template.err}\n`; + default: + throw new Error('Invalid message type'); + } +} diff --git a/src/util/Util.ts b/src/util/Util.ts index c09045f..ff7de6b 100644 --- a/src/util/Util.ts +++ b/src/util/Util.ts @@ -3,9 +3,9 @@ import { existsSync, readFileSync } from 'fs'; import { AiModels } from '../types/AiModels'; import { IModelConfig, IModelType } from '../types/Config'; + export class Util { public static getModelByPrefix(message: string): AiModels | undefined { - // models for (let [modelName, model] of Object.entries(config.models)) { if ( !(model as IModelConfig).enable && @@ -44,4 +44,4 @@ export class Util { return readFileSync(filePath, 'utf-8'); } -} +} \ No newline at end of file diff --git a/src/whatsapp-ai.config.ts b/src/whatsapp-ai.config.ts index 6a94ae3..7c4489c 100644 --- a/src/whatsapp-ai.config.ts +++ b/src/whatsapp-ai.config.ts @@ -1,5 +1,6 @@ /* Models config files */ import { Config } from './types/Config'; +import { ENV } from './baileys/env'; const config: Config = { chatGPTModel: 'gpt-3.5-turbo', // learn more about GPT models https://platform.openai.com/docs/models From 937e71d0ae935885eb95882f3ec219c7e9e23ef1 Mon Sep 17 00:00:00 2001 From: vicentefelipechile Date: Fri, 18 Oct 2024 12:05:28 -0300 Subject: [PATCH 10/12] Update .env.example and README.md --- .env.example | 15 +++++++++++---- README.md | 10 ++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 2195626..fa9dce8 100644 --- a/.env.example +++ b/.env.example @@ -10,15 +10,22 @@ API_KEY_HF=HUGGING_FACE_TOKEN # API_KEY_OPENAI_DALLE=ADD_YOUR_KEY # MongoDB +MONGO_ENABLED=True MONGO_URL=YOUR_MONGO_DB_URL # Service Settings -## OpenAI - +# # OpenAI OPENAI_PREFIX=!chatgpt -OPENAI_ENABLED=True +OPENAI_ENABLED=False +OPENAI_ICON_PREFIX=🤖 DALLE_PREFIX=!dalle DALLE_ENABLED=True -DALLE_USE_3=False \ No newline at end of file +DALLE_ICON_PREFIX=🎨 +DALLE_USE_3=False + +# # Google Gemini +GEMINI_PREFIX=!gemini +GEMINI_ENABLED=True +GEMINI_ICON_PREFIX=🔮 \ No newline at end of file diff --git a/README.md b/README.md index 20e0213..395373b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,10 @@ -The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses to user input. The bot supports several AI models, including **`Gemini`**, **`Gemini-Vision`**, **`CHAT-GPT`**, **`DALL-E`**, and **`Stability AI`**, and users can also create their **`own models`** to customize the bot's behavior. +The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses to user input. The bot supports several AI models, including **`Gemini`**, **`ChatGPT`** and **`DALL-E`**.. + +> [!NOTE] +> Custom models aren't supported for now, but we are working on it. # Table of Content @@ -96,13 +99,8 @@ Copy the file `.env.example` and rename it to `.env`, then set any settings you # Default Settings - `!gemini` use gemini. -- `!gemini-vision` use `gemini-pro-vision` model for images - `!chatgpt` use chat-gpt. - `!dalle` use Dalle. -- `!dalle3` use Dalle 3. -- `!stable` use Stability AI. -- `!flux` use flux AI. -- `!bot` use custom model. **Note! open `src/whatsapp-ai.config.ts` to edit config.** From 0a5157d4332d3f486b260e9d865c2194dcac5437 Mon Sep 17 00:00:00 2001 From: vicentefelipechile Date: Fri, 18 Oct 2024 15:07:32 -0300 Subject: [PATCH 11/12] final commit --- src/baileys/env.ts | 48 ++++++---- src/baileys/handlers/message.ts | 59 +++++++----- src/baileys/handlers/messages.ts | 1 - src/baileys/hooks/useMessageParser.ts | 28 +++++- src/baileys/index.ts | 4 +- src/models/BaseAiModel.ts | 41 +++++++-- src/models/DalleModel.ts | 65 -------------- src/models/FluxModel.ts | 4 +- src/models/GeminiModel.ts | 123 ++++++++++++++++---------- src/models/GeminiVisionModel.ts | 4 +- src/models/OpenAIModel.ts | 47 ++++++---- src/models/StabilityModel.ts | 73 --------------- src/services/welcomeUser.ts | 34 ------- src/types/AiModels.d.ts | 9 +- src/types/Config.d.ts | 19 ++-- src/util/Util.ts | 40 +++------ src/whatsapp-ai.config.ts | 61 +++++-------- static/whatsapp-ai-bot.md | 1 - 18 files changed, 288 insertions(+), 373 deletions(-) delete mode 100644 src/models/DalleModel.ts delete mode 100644 src/models/StabilityModel.ts delete mode 100644 src/services/welcomeUser.ts delete mode 100644 static/whatsapp-ai-bot.md diff --git a/src/baileys/env.ts b/src/baileys/env.ts index 66ddebe..d69b6b7 100644 --- a/src/baileys/env.ts +++ b/src/baileys/env.ts @@ -5,40 +5,56 @@ configEnv(); interface EnvInterface { Debug: boolean; + Processing: string; // Model Services - API_KEY_OPENAI: string | undefined; - API_KEY_OPENAI_DALLE: string | undefined; - API_KEY_DREAMSTUDIO: string | undefined; - API_KEY_GEMINI: string | undefined; - API_KEY_HF: string | undefined; + API_KEY_OPENAI?: string; + API_KEY_OPENAI_DALLE?: string; + API_KEY_DREAMSTUDIO?: string; + API_KEY_GEMINI?: string; + API_KEY_HF?: string; // MongoDB - MONGO_URL: string | undefined; + MONGO_ENABLED: boolean; + MONGO_URL?: string; // Services // // OpenAI - OPENAI_PREFIX: string | undefined; + OPENAI_PREFIX?: string; OPENAI_ENABLED: boolean; + OPENAI_ICON_PREFIX?: string; - DALLE_PREFIX: string | undefined; + DALLE_PREFIX?: string; DALLE_ENABLED: boolean; + DALLE_ICON_PREFIX?: string; DALLE_USE_3: boolean; + + // // Google Gemini + GEMINI_PREFIX?: string; + GEMINI_ENABLED: boolean; + GEMINI_ICON_PREFIX?: string; } export const ENV: EnvInterface = { - API_KEY_OPENAI: process.env.OPENAI_API_KEY, - API_KEY_OPENAI_DALLE: process.env.OPENAI_DALLE_API_KEY || process.env.OPENAI_API_KEY, - API_KEY_DREAMSTUDIO: process.env.DREAMSTUDIO_API_KEY, - API_KEY_GEMINI: process.env.GEMINI_API_KEY, - API_KEY_HF: process.env.HF_TOKEN, - MONGO_URL: process.env.MONGO_URL, - Debug: process.env.DEBUG === 'True', + Processing: process.env.PROCESSING || 'Processing...', + + API_KEY_OPENAI: process.env.API_KEY_OPENAI, + API_KEY_OPENAI_DALLE: process.env.API_KEY_OPENAI_DALLE || process.env.API_KEY_OPENAI, + API_KEY_DREAMSTUDIO: process.env.API_KEY_DREAMSTUDIO, + API_KEY_GEMINI: process.env.API_KEY_GEMINI, + API_KEY_HF: process.env.API_KEY_HF, + MONGO_ENABLED: process.env.MONGO_ENABLED === 'True', + MONGO_URL: process.env.MONGO_URL, OPENAI_PREFIX: process.env.OPENAI_PREFIX, OPENAI_ENABLED: process.env.OPENAI_ENABLED === 'True', + OPENAI_ICON_PREFIX: process.env.OPENAI_ICON_PREFIX, DALLE_PREFIX: process.env.DALLE_PREFIX, DALLE_ENABLED: process.env.DALLE_ENABLED === 'True', - DALLE_USE_3: process.env.DALLE_USE_3 === 'True' + DALLE_ICON_PREFIX: process.env.DALLE_ICON_PREFIX, + DALLE_USE_3: process.env.DALLE_USE_3 === 'True', + GEMINI_PREFIX: process.env.GEMINI_PREFIX, + GEMINI_ENABLED: process.env.GEMINI_ENABLED === 'True', + GEMINI_ICON_PREFIX: process.env.GEMINI_ICON_PREFIX }; diff --git a/src/baileys/handlers/message.ts b/src/baileys/handlers/message.ts index a228c84..db94390 100644 --- a/src/baileys/handlers/message.ts +++ b/src/baileys/handlers/message.ts @@ -1,49 +1,66 @@ /* Third-party modules */ -import { AnyMessageContent, downloadMediaMessage } from '@whiskeysockets/baileys'; +import { AnyRegularMessageContent, downloadMediaMessage } from '@whiskeysockets/baileys'; /* Local modules */ import MessageHandlerParams from './../aimodeltype'; -import { AiModels } from './../../types/AiModels'; +import { AIModels } from './../../types/AiModels'; import { Util } from './../../util/Util'; /* Models */ import { ChatGPTModel } from './../../models/OpenAIModel'; import { GeminiModel } from './../../models/GeminiModel'; import { FluxModel } from './../../models/FluxModel'; +import { ENV } from '../env'; /* Declare models */ -const modelTable: Record = { - "ChatGPT": new ChatGPTModel(), - "Gemini": new GeminiModel(), - "FLUX": new FluxModel(), - Custom: undefined +const modelTable: Record = { + ChatGPT: ENV.OPENAI_ENABLED ? new ChatGPTModel() : null, + Gemini: ENV.GEMINI_ENABLED ? new GeminiModel() : null, + FLUX: new FluxModel() }; - // handles message export async function handleMessage({ client, msg, metadata }: MessageHandlerParams) { - const modelToUse = Util.getModelByPrefix(metadata.text) as AiModels; - if (!modelToUse) return; + const modelToUse = Util.getModelByPrefix(metadata.text) as AIModels; + if (!modelToUse) { + if (ENV.Debug) { + console.log("[Debug] Model '" + (modelToUse as string) + "' not found"); + } - const prompt: string = metadata.text.split(' ').slice(1).join(' '); + return; + } - // handle models const model = modelTable[modelToUse]; if (!model) return; - model.sendMessage({ sender: metadata.sender, prompt: prompt, metadata: metadata }, async (res: AnyMessageContent, err: any) => { - if ( err ) { - console.log(err); - return; - } + const prompt: string = metadata.text.split(' ').slice(1).join(' '); + const messageResponse = await client.sendMessage( + metadata.remoteJid, + { text: ENV.Processing }, + { quoted: msg } + ); + + model.sendMessage( + { sender: metadata.sender, prompt: prompt, metadata: metadata }, + async (res: any, err: any) => { + if (err) { + client.sendMessage(metadata.remoteJid, { + text: "Sorry, i can't handle your request right now.", + edit: messageResponse?.key + }); + console.error(err); + return; + } + res.edit = messageResponse?.key; - client.sendMessage(metadata.remoteJid, res, { quoted: msg }); - }); + client.sendMessage(metadata.remoteJid, res); + } + ); } // handles message from self export async function handlerMessageFromMe({ metadata, client, msg, type }: MessageHandlerParams) { - if (metadata.fromMe && metadata.isQuoted) return; - if (metadata.isQuoted && Util.getModelByPrefix(metadata.text)) return; + // if (metadata.fromMe && metadata.isQuoted) return; + // if (metadata.isQuoted && Util.getModelByPrefix(metadata.text)) return; await handleMessage({ metadata, client, msg, type }); } diff --git a/src/baileys/handlers/messages.ts b/src/baileys/handlers/messages.ts index d0c2a72..2f5cb4e 100644 --- a/src/baileys/handlers/messages.ts +++ b/src/baileys/handlers/messages.ts @@ -20,7 +20,6 @@ export function messagesHandler({ if (!metadata) return; if (metadata.msgType === 'unknown') return; - // prevent message from locked group if (metadata.isGroup && metadata.groupMetaData.groupIsLocked) return; await (metadata.fromMe diff --git a/src/baileys/hooks/useMessageParser.ts b/src/baileys/hooks/useMessageParser.ts index 5c33163..bff713d 100644 --- a/src/baileys/hooks/useMessageParser.ts +++ b/src/baileys/hooks/useMessageParser.ts @@ -51,6 +51,17 @@ export default async function useMessageParser( msgType, type, isQuoted: false, + quoteMetaData: { + remoteJid: '', + message: {}, + text: '', + type: 'text', + imgMetaData: { + url: '', + mimeType: '', + caption: '' + } + }, timeStamp: message.messageTimestamp ? new Date((message.messageTimestamp as number) * 1000) : new Date(), @@ -92,7 +103,22 @@ export default async function useMessageParser( // gather context info if (extendedTextMessage) { const { contextInfo } = extendedTextMessage; - if (contextInfo && contextInfo.quotedMessage) metaData.isQuoted = true; + + if (contextInfo && contextInfo.quotedMessage) { + metaData.isQuoted = true; + + metaData.quoteMetaData.remoteJid = contextInfo.remoteJid || ''; + metaData.quoteMetaData.text = contextInfo.quotedMessage?.conversation || ''; + metaData.quoteMetaData.message = contextInfo.quotedMessage || {}; + + if (contextInfo.quotedMessage.imageMessage) { + metaData.quoteMetaData.type = 'image'; + metaData.quoteMetaData.imgMetaData.url = contextInfo.quotedMessage.imageMessage.url || ''; + metaData.quoteMetaData.imgMetaData.mimeType = + contextInfo.quotedMessage.imageMessage.mimetype || ''; + metaData.quoteMetaData.text = contextInfo.quotedMessage.imageMessage.caption || ''; + } + } } // Check if the message is from a group diff --git a/src/baileys/index.ts b/src/baileys/index.ts index b7743d9..7723432 100644 --- a/src/baileys/index.ts +++ b/src/baileys/index.ts @@ -14,9 +14,7 @@ import { ENV } from './env'; /* Util */ const connectToDatabase = async () => { - const UseMongoDB: boolean = ENV.MONGO_URL !== undefined; - - if (UseMongoDB) { + if (ENV.MONGO_ENABLED) { return await useMongoDBAuthState( ( await connectToMongoDB() ).collection as any ); diff --git a/src/models/BaseAiModel.ts b/src/models/BaseAiModel.ts index 3962451..f3e23ee 100644 --- a/src/models/BaseAiModel.ts +++ b/src/models/BaseAiModel.ts @@ -1,7 +1,9 @@ import { MessageUpsertType } from '@whiskeysockets/baileys'; -import { AiModels } from '../types/AiModels'; +import { AIModels } from '../types/AiModels'; -type MetaData = { +type AIHandle = (res: any, error?: string) => Promise; + +type AIMetaData = { remoteJid: string; sender: string; senderName?: string; @@ -9,6 +11,17 @@ type MetaData = { msgType: 'unknown' | 'text' | 'extendedText' | 'image' | 'video' | 'document' | 'contact' | 'location' | 'audio'; type: MessageUpsertType; isQuoted: boolean; + quoteMetaData: { + remoteJid: string; + message: any; + text: string; + type: 'text' | 'image'; + imgMetaData: { + url: string; + mimeType: string; + caption: string; + }; + }; timeStamp: Date; text: string; isGroup: boolean; @@ -30,24 +43,34 @@ type MetaData = { interface AIArguments { sender: string; prompt: string; - metadata: MetaData; + metadata: AIMetaData; prefix: string; } -abstract class AiModel { +abstract class AIModel { /* Variables */ private apiKey: string; - public modelName: AiModels; + public history: { [from: string]: any[] }; + public modelName: AIModels; + public iconPrefix: string; /* Methods */ - public constructor(apiKey: string | undefined, aiModelName: AiModels) { + public constructor(apiKey: string | undefined, modelName: AIModels, icon?: string) { this.apiKey = apiKey || 'undefined'; - this.modelName = aiModelName; + this.modelName = modelName; + + this.history = {}; + this.iconPrefix = icon === undefined ? '' : '[' + icon + '] '; } - public getApiKey(): string { return this.apiKey; } + public getApiKey(): string { return this.apiKey }; + public sessionCreate(user: string): void { this.history[user] = [] }; + public sessionRemove(user: string): void { delete this.history[user] }; + public sessionExists(user: string): boolean { return this.history[user] !== undefined }; + public sessionAddMessage(user: string, args: any): void { this.history[user].push(args) }; + public addPrefixIcon(text: string): string { return this.iconPrefix + text }; abstract sendMessage(args: AIArguments, handle: CallBack): Promise; } -export { AiModel, AIArguments }; +export { AIModel, AIArguments, AIHandle, AIMetaData }; diff --git a/src/models/DalleModel.ts b/src/models/DalleModel.ts deleted file mode 100644 index 914cb09..0000000 --- a/src/models/DalleModel.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { AiModel } from './BaseAiModel'; -import { useSpinner } from '../hooks/useSpinner'; -import OpenAI from 'openai'; - -import { MessageTemplates } from '../util/MessageTemplates'; -import { ENV } from '../baileys/env'; - -interface DalleModelParams { - sender: string; - prompt: string; -} - -type HandleType = ( - { url, caption }: { url: string; caption?: string }, - error?: string -) => Promise; - -class DalleModel extends AiModel { - public constructor(modelName: 'DALLE' | 'DALLE3') { - super(ENV.API_KEY_OPENAI, modelName); - this.client = new OpenAI({ apiKey: this.getApiKey() }); - } - - public async sendMessage( - { sender, prompt }: DalleModelParams, - handle: HandleType - ): Promise { - const spinner = useSpinner(MessageTemplates.requestStr(this.aiModelName, sender, prompt)); - spinner.start(); - try { - const startTime = Date.now(); - - const res = await this.client.images.generate({ - model: this.aiModelName === 'DALLE3' ? 'dall-e-3' : 'dall-e-2', - n: 1, - size: '512x512', - prompt - }); - - await handle({ url: res.data[0].url as string, caption: res.data[0].revised_prompt }); - - spinner.succeed( - MessageTemplates.reqSucceedStr( - this.aiModelName, - sender, - res.data[0].url as string, - Date.now() - startTime - ) - ); - } catch (err) { - spinner.fail( - MessageTemplates.reqFailStr( - this.aiModelName, - 'at DalleModel.ts sendMessage(prompt, handle)', - err - ) - ); - await handle({ url: '' }, 'An error occur please see console for more information.'); - } - } - - private client: OpenAI; -} - -export { DalleModel }; diff --git a/src/models/FluxModel.ts b/src/models/FluxModel.ts index d0772fd..fb3386b 100644 --- a/src/models/FluxModel.ts +++ b/src/models/FluxModel.ts @@ -1,7 +1,7 @@ import { useSpinner } from '../hooks/useSpinner'; import { ENV } from '../baileys/env'; import { MessageTemplates } from '../util/MessageTemplates'; -import { AiModel } from './BaseAiModel'; +import { AIModel } from './BaseAiModel'; interface FluxAiModelParams { sender: string; @@ -10,7 +10,7 @@ interface FluxAiModelParams { type HandleType = (res: Buffer, err?: string) => Promise; -class FluxModel extends AiModel { +class FluxModel extends AIModel { constructor() { super(ENV.HFKey, 'FLUX'); } diff --git a/src/models/GeminiModel.ts b/src/models/GeminiModel.ts index 3ffb771..66b274e 100644 --- a/src/models/GeminiModel.ts +++ b/src/models/GeminiModel.ts @@ -1,67 +1,98 @@ -import { AiModel } from './BaseAiModel'; -import { ENV } from '../baileys/env'; -import { useSpinner } from '../hooks/useSpinner'; -import { MessageTemplates } from '../util/MessageTemplates'; -import { Content, GoogleGenerativeAI } from '@google/generative-ai'; +/* Third-party modules */ +import { + ChatSession, + InlineDataPart, + GenerativeModel, + GoogleGenerativeAI +} from '@google/generative-ai'; +import { + AnyMessageContent, + downloadMediaMessage, + generateWAMessage +} from '@whiskeysockets/baileys'; -interface GeminiModelParams { - sender: string; - prompt: string; -} +/* Local modules */ +import { AIModel, AIArguments, AIHandle, AIMetaData } from './BaseAiModel'; +import { ENV } from '../baileys/env'; -type HandleType = (res: string, error?: string) => Promise; +/* Gemini Model */ +class GeminiModel extends AIModel { + /* Variables */ + private generativeModel: GenerativeModel; + private Gemini: GoogleGenerativeAI; + public chats: { [from: string]: ChatSession }; -class GeminiModel extends AiModel { public constructor() { - super(ENV.geminiKey, 'Gemini'); - this.genAI = new GoogleGenerativeAI(this.apiKey); - this.history = {}; - } + super(ENV.API_KEY_GEMINI, 'Gemini', ENV.GEMINI_ICON_PREFIX); + this.Gemini = new GoogleGenerativeAI(ENV.API_KEY_GEMINI as string); - async sendMessage({ sender, prompt }: GeminiModelParams, handle: HandleType): Promise { - const spinner = useSpinner(MessageTemplates.requestStr(this.aiModelName, sender, prompt)); - spinner.start(); + // https://ai.google.dev/gemini-api/docs/models/gemini + this.generativeModel = this.Gemini.getGenerativeModel({ model: 'gemini-1.5-flash' }); + this.chats = {}; + } - try { - const startTime = Date.now(); + /* Methods */ + public async generateCompletion(user: string, prompt: string): Promise { + if (!this.sessionExists(user)) { + this.sessionCreate(user); + this.chats[user] = this.generativeModel.startChat(); + } - // check out more at: https://ai.google.dev/tutorials/node_quickstart - const model = this.genAI.getGenerativeModel({ model: 'gemini-1.5-flash' }); + const chat = this.chats[user]; + return (await chat.sendMessage(prompt)).response.text(); + } - const chat = model.startChat({ - history: this.history[sender] - }); + public createGenerativeContent(buffer: Buffer, mimeType: string): InlineDataPart { + return { + inlineData: { + data: buffer.toString('base64'), + mimeType + } + }; + } - const res = await chat.sendMessage(prompt); + public async generateImageCompletion(prompt: string, metadata: AIMetaData): Promise { + const { mimeType } = metadata.quoteMetaData.imgMetaData; + if (mimeType === 'image/jpeg') { + const buffer = await downloadMediaMessage( + { message: metadata.quoteMetaData.message } as any, + 'buffer', + {} + ); + const imageParts = this.createGenerativeContent(buffer, mimeType); + const result = await this.generativeModel.generateContent([prompt, imageParts]); + const resultText = result.response.text(); - // TODO: handle usage metadata + return resultText; + } - const resText = res.response.text(); + return ''; + } - // push conversation to history - if (this.history[sender] === undefined) this.history[sender] = []; - this.history[sender].push({ role: 'user', parts: [{ text: prompt }] }); - this.history[sender].push({ role: 'model', parts: [{ text: resText }] }); + async sendMessage({ sender, prompt, metadata }: AIArguments, handle: AIHandle) { + try { + let message = ''; + console.log(metadata.quoteMetaData); - await handle(resText); + if (metadata.isQuoted) { + if (metadata.quoteMetaData.type === 'image') { + message = this.iconPrefix + (await this.generateImageCompletion(prompt, metadata)); + } else { + prompt = 'Quoted Message:\n' + metadata.quoteMetaData.text + '---\nMessage:\n' + prompt; + message = this.iconPrefix + (await this.generateCompletion(sender, prompt)); + } + } else { + message = this.iconPrefix + (await this.generateCompletion(sender, prompt)); + } - spinner.succeed( - MessageTemplates.reqSucceedStr(this.aiModelName, sender, resText, Date.now() - startTime) - ); + handle({ text: message }); } catch (err) { - spinner.fail( - MessageTemplates.reqFailStr( - this.aiModelName, - 'at GeminiModel.ts sendMessage(prompt, msg)', - err - ) + handle( + '', + '[Error] An error occur please see console for more information.\n[Error] Message:\n' + err ); - handle('', 'An error occur please see console for more information.'); } } - - private genAI: GoogleGenerativeAI; - private history: { [sender: string]: Content[] }; } export { GeminiModel }; diff --git a/src/models/GeminiVisionModel.ts b/src/models/GeminiVisionModel.ts index 025fb4f..cea61de 100644 --- a/src/models/GeminiVisionModel.ts +++ b/src/models/GeminiVisionModel.ts @@ -1,4 +1,4 @@ -import { AiModel } from './BaseAiModel'; +import { AIModel } from './BaseAiModel'; import { ENV } from '../baileys/env'; import { GoogleGenerativeAI } from '@google/generative-ai'; import { useSpinner } from '../hooks/useSpinner'; @@ -11,7 +11,7 @@ interface GeminiVisionModelParams { type HandleType = (res: string, error?: string) => Promise; -class GeminiVisionModel extends AiModel { +class GeminiVisionModel extends AIModel { public constructor() { super(ENV.geminiKey, 'GeminiVision', 'Image'); this.genAI = new GoogleGenerativeAI(this.apiKey); diff --git a/src/models/OpenAIModel.ts b/src/models/OpenAIModel.ts index 815a029..c19c9b2 100644 --- a/src/models/OpenAIModel.ts +++ b/src/models/OpenAIModel.ts @@ -1,16 +1,26 @@ /* Third-party modules */ -import { ChatCompletionMessageParam, ChatCompletionMessage } from 'openai/resources/chat/completions'; +import { + ChatCompletionMessageParam, + ChatCompletionMessage +} from 'openai/resources/chat/completions'; import OpenAI from 'openai'; /* Local modules */ -import { AiModel, AIArguments } from './BaseAiModel'; +import { AIModel, AIArguments } from './BaseAiModel'; import { ENV } from '../baileys/env'; import config from '../whatsapp-ai.config'; +/* Util */ type HandleType = (res: string, error?: string) => Promise; -class ChatGPTModel extends AiModel { - private history: { [from: string]: ChatCompletionMessageParam[] }; +interface BotImageResponse { + url: string; + caption: string; +} + +/* ChatGPT Model */ +class ChatGPTModel extends AIModel { + /* Variables */ private Dalle3: boolean; private Dalle: OpenAI; private OpenAI: OpenAI; @@ -26,18 +36,14 @@ class ChatGPTModel extends AiModel { apiKey: ENV.API_KEY_OPENAI_DALLE }); - this.history = {}; - this.Dalle3 = ENV.DALLE_USE_3; + this.Dalle3 = config.models.ChatGPT?.settings.dalle_use_3; } - public sessionCreate(user: string): void { this.history[user] = [] }; - public sessionExists(user: string): boolean { return this.history[user] !== undefined }; - public sessionAddMessage(user: string, args: any): void { this.history[user].push(args) }; - + /* Methods */ public async generateCompletion(user: string): Promise { const completion = await this.OpenAI.chat.completions.create({ messages: this.history[user], - model: config.chatGPTModel + model: config.models.ChatGPT?.modelToUse?.toString() || 'gpt-3.5-turbo' }); const message = completion.choices[0].message; @@ -46,18 +52,27 @@ class ChatGPTModel extends AiModel { return message; } - public async generateImage() { + public async generateImage(prompt: string): Promise { + const res: OpenAI.Images.ImagesResponse = await this.Dalle.images.generate({ + model: this.Dalle3 ? 'dall-e-3' : 'dall-e-2', + n: 1, + size: '512x512', + prompt: prompt + }); + const resInfo: OpenAI.Images.Image = res.data[0]; + + return { url: resInfo.url as string, caption: resInfo.revised_prompt as string }; } public async sendMessage({ sender, prompt }: AIArguments, handle: HandleType): Promise { try { - if ( !this.sessionExists(sender) ) { this.sessionCreate(sender) }; - + if (!this.sessionExists(sender)) { + this.sessionCreate(sender); + } this.sessionAddMessage(sender, { role: 'user', content: prompt }); const completion = await this.generateCompletion(sender); - const res = completion.content || ''; await handle(res); } catch (err) { @@ -66,4 +81,4 @@ class ChatGPTModel extends AiModel { } } -export { ChatGPTModel }; \ No newline at end of file +export { ChatGPTModel }; diff --git a/src/models/StabilityModel.ts b/src/models/StabilityModel.ts deleted file mode 100644 index 6fb8d41..0000000 --- a/src/models/StabilityModel.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { AiModel } from './BaseAiModel'; -import fetch from 'node-fetch'; -import { useSpinner } from '../hooks/useSpinner'; -import type { Message } from 'whatsapp-web.js'; -import { MessageMedia } from 'whatsapp-web.js'; -import { MessageTemplates } from '../util/MessageTemplates'; -import { ENV } from '../baileys/env'; - -class StabilityModel extends AiModel { - public constructor() { - super(ENV.dreamStudioKey, 'StableDiffusion'); - } - - public async sendMessage(prompt: string, msg: Message): Promise { - const spinner = useSpinner(MessageTemplates.requestStr(this.aiModelName, msg.from, prompt)); - spinner.start(); - - try { - const startTime = Date.now(); - const engineId = "stable-diffusion-v1-6"; - const apiHost = process.env.API_HOST || 'https://api.stability.ai'; - - if (!this.apiKey) { - throw new Error("Missing Stability API key."); - } - - const response = await fetch(`${apiHost}/v1/generation/${engineId}/text-to-image`, { - method: 'POST', - headers: { - "Content-Type": "application/json", - "Accept": "application/json", - "Authorization": `Bearer ${this.apiKey}` - }, - body: JSON.stringify({ - "text_prompts": [ - { - "text": prompt - } - ], - "cfg_scale": 7, - "height": 512, - "width": 512, - "samples": 1, - "steps": 30, - }), - }); - - if (!response.ok) { - throw new Error(`API call failed with HTTP status ${response.status}`); - } - - const data = await response.json(); - const images = data.artifacts || []; - - if (images.length === 0) { - throw new Error("No images were generated."); - } - - const imageBuffer = Buffer.from(images[0].base64, 'base64'); - const base64String = imageBuffer.toString('base64'); - const image = new MessageMedia('image/jpeg', base64String, 'image.jpg'); - - msg.reply(image); - spinner.succeed(MessageTemplates.reqSucceedStr(this.aiModelName, msg.from, '', Date.now() - startTime)); - } catch (err) { - console.error(err); - spinner.fail(MessageTemplates.reqFailStr(this.aiModelName, 'at StabilityModel.ts sendMessage(prompt, msg)', err)); - msg.reply('An error occurred. Please see console for more information.'); - } - } - } - - export { StabilityModel }; diff --git a/src/services/welcomeUser.ts b/src/services/welcomeUser.ts deleted file mode 100644 index 67370e8..0000000 --- a/src/services/welcomeUser.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Message } from 'whatsapp-web.js'; -import { WhatsAppClient } from '../lib/WhatsAppClient'; -import config from '../whatsapp-ai.config'; - -/** - * ensure send one message per session - */ -var sended = false; - -const welcomeMessage = ` -✨ Thank you for checking out Whats App AI Bot. - ---- *Repository link* --- - -https://github.com/Zain-ul-din/whatsapp-ai-bot - ---- *Report bug here* --- - -https://github.com/Zain-ul-din/whatsapp-ai-bot/issues/new - ---- *Our website link* --- - -for feature request and deployment: https://wa-ai-seven.vercel.app/ - -`; - -export default function welcomeUser(msg: Message, client: WhatsAppClient) { - if (!config.sendWelcomeMessage) return; - if (sended) return; - sended = true; - console.log(client); - const sender = msg.from; - client.self().sendMessage(sender, welcomeMessage); -} diff --git a/src/types/AiModels.d.ts b/src/types/AiModels.d.ts index b624a7d..d96c646 100644 --- a/src/types/AiModels.d.ts +++ b/src/types/AiModels.d.ts @@ -1,7 +1,2 @@ -export type AiModels = - | 'ChatGPT' - | 'Gemini' - | 'Custom' - | 'FLUX'; - -export type AiModelsName = Exclude; +export type AIModels = 'ChatGPT' | 'Gemini' | 'FLUX'; +export type AIModelsName = Exclude; diff --git a/src/types/Config.d.ts b/src/types/Config.d.ts index 42ebd24..7965bf8 100644 --- a/src/types/Config.d.ts +++ b/src/types/Config.d.ts @@ -1,35 +1,36 @@ -import { AiModels, AiModelsName } from './AiModels'; +import { AIModels, AIModelsName } from './AiModels'; export interface IModelConfig { - prefix: string; - enable?: boolean; + prefix: string | undefined; + enable: boolean; + modelToUse?: string; + settings?: any; } export interface IModelType extends IModelConfig { modelName: string; prefix: string; context: string; - modelToUse?: AiModelsName; + modelToUse?: AIModelsName; includeSender?: boolean; } export interface IDefaultConfig { - enable?: boolean; + enabled: boolean; /** default model to use when prefix is disabled*/ - defaultModel: AiModels; + defaultModel: AIModels; } export type Config = { models: { - [key in AiModels]?: key extends 'Custom' ? Array | [] : IModelConfig | null; + [key in AIModels]?: key extends 'Custom' ? Array | [] : IModelConfig | null; }; } & { - enablePrefix: IDefaultConfig; + prefix: IDefaultConfig; sessionStorage: { enable: boolean; wwjsPath: string; }; - chatGPTModel: string; sendWelcomeMessage: boolean; selfMessage: { skipPrefix: boolean; diff --git a/src/util/Util.ts b/src/util/Util.ts index ff7de6b..c937ea0 100644 --- a/src/util/Util.ts +++ b/src/util/Util.ts @@ -1,38 +1,18 @@ -import config from '../whatsapp-ai.config'; import { existsSync, readFileSync } from 'fs'; -import { AiModels } from '../types/AiModels'; -import { IModelConfig, IModelType } from '../types/Config'; - +import { IModelConfig } from '../types/Config'; +import { AIModels } from '../types/AiModels'; +import config from '../whatsapp-ai.config'; export class Util { - public static getModelByPrefix(message: string): AiModels | undefined { + public static getModelByPrefix(message: string): AIModels | undefined { for (let [modelName, model] of Object.entries(config.models)) { - if ( - !(model as IModelConfig).enable && - (modelName as AiModels) != 'Custom' // ignore array - ) - continue; + const currentModel = model as IModelConfig; + if (!currentModel.enable) continue; - if ((modelName as AiModels) == 'Custom') { - return Util.getModelByCustomPrefix(message); - } else if ( - model && - message.toLocaleLowerCase().startsWith((model as IModelConfig)?.prefix.toLocaleLowerCase()) + if ( + message.toLocaleLowerCase().startsWith((currentModel.prefix as string).toLocaleLowerCase()) ) { - return modelName as AiModels; - } - } - - return undefined; - } - - private static getModelByCustomPrefix(message: string): AiModels | undefined { - if (!config.models.Custom) return undefined; - for (let model of config.models.Custom) { - if (!(model as IModelType).enable) continue; - - if (message.toLocaleLowerCase().startsWith(model.prefix.toLocaleLowerCase())) { - return model.modelName as AiModels; + return modelName as AIModels; } } @@ -44,4 +24,4 @@ export class Util { return readFileSync(filePath, 'utf-8'); } -} \ No newline at end of file +} diff --git a/src/whatsapp-ai.config.ts b/src/whatsapp-ai.config.ts index 7c4489c..3cf48d6 100644 --- a/src/whatsapp-ai.config.ts +++ b/src/whatsapp-ai.config.ts @@ -3,63 +3,50 @@ import { Config } from './types/Config'; import { ENV } from './baileys/env'; const config: Config = { - chatGPTModel: 'gpt-3.5-turbo', // learn more about GPT models https://platform.openai.com/docs/models sendWelcomeMessage: true, // Whether to send a welcome message to the user (located at /src/services/welcomeUser.ts) models: { ChatGPT: { - prefix: '!chatgpt', // Prefix for the ChatGPT model - enable: true // Whether the ChatGPT model is enabled or not - }, - DALLE3: { - prefix: '!dalle3', // Prefix for the DALLE-3 model - enable: true - }, - DALLE: { - prefix: '!dalle', // Prefix for the DALLE model - enable: true // Whether the DALLE model is enabled or not - }, - StableDiffusion: { - prefix: '!stable', // Prefix for the StableDiffusion model - enable: true // Whether the StableDiffusion model is enabled or not - }, - GeminiVision: { - prefix: '!gemini-vision', // Prefix for the GeminiVision model - enable: true // Whether the GeminiVision model is enabled or not + prefix: ENV.OPENAI_PREFIX, + enable: ENV.OPENAI_ENABLED, + modelToUse: 'gpt-3.5-turbo', // See all models here https://platform.openai.com/docs/models + settings: { + dalle_enabled: ENV.DALLE_ENABLED, + dalle_prefix: ENV.DALLE_PREFIX, + dalle_use_3: ENV.DALLE_USE_3 + } }, Gemini: { - prefix: '!gemini', // Prefix for the Gemini model - enable: true // Whether the Gemini model is enabled or not + prefix: '!gemini', + enable: true }, FLUX: { prefix: '!flux', enable: true - }, + } + /* Custom: [ { - /** Custom Model */ + // Custom Model modelName: 'whatsapp-ai-bot', // Name of the custom model prefix: '!bot', // Prefix for the custom model enable: true, // Whether the custom model is enabled or not - /** - * context: "file-path (.txt, .text, .md)", - * context: "text url", - * context: "text" - */ + // + // context: "file-path (.txt, .text, .md)", + // context: "text url", + // context: "text" + context: './static/whatsapp-ai-bot.md' // Context for the custom model } ] + */ }, - enablePrefix: { - /** if enable, reply to those messages start with prefix */ - enable: true, // Whether prefix messages are enabled or not - /** default model to use if message not starts with prefix and enable is false */ - defaultModel: 'ChatGPT' // Default model to use if no prefix is present in the message + prefix: { + enabled: true, // If you disable this, the bot will reply to all messages + defaultModel: 'ChatGPT' }, sessionStorage: { - /** Enable or disable session storage */ - enable: true, // Whether session storage is enabled or not - /** Session storage path */ - wwjsPath: './' // Path for the session storage + enable: true, // We should save the session storage? + wwjsPath: './' }, selfMessage: { /** Skip prefix for self messages */ diff --git a/static/whatsapp-ai-bot.md b/static/whatsapp-ai-bot.md deleted file mode 100644 index 259ea76..0000000 --- a/static/whatsapp-ai-bot.md +++ /dev/null @@ -1 +0,0 @@ -The WhatsApp AI Bot is a chatbot that uses AI models APIs to generate responses to user input. The bot supports several AI models, including CHAT-GPT, DALL-E, and Stability AI, and users can also create their own models to customize the bot's behavior. \ No newline at end of file From be80dc898de44dcfa674d85ad280985e74e7c2b2 Mon Sep 17 00:00:00 2001 From: vicentefelipechile Date: Fri, 18 Oct 2024 15:10:12 -0300 Subject: [PATCH 12/12] Update readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 395373b..31e5f11 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Copy the file `.env.example` and rename it to `.env`, then set any settings you ### 4. Run the code -- Run `setup.sh` to start the bot +- Run `npm run start` to run the bot. - Scan QR code.