{"id":14956950,"url":"https://github.com/iamrony777/baileys","last_synced_at":"2025-09-30T03:30:33.146Z","repository":{"id":177760459,"uuid":"656179768","full_name":"iamrony777/Baileys","owner":"iamrony777","description":"A fork of Baileys with Mongodb and redis support ","archived":false,"fork":true,"pushed_at":"2025-01-06T10:25:12.000Z","size":13539,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-06T10:37:24.957Z","etag":null,"topics":["baileys","baileys-bot","baileys-lib","baileys-md","bot","mongodb","mongodb-database","redis","whatsapp","whatsapp-api","whatsapp-bot"],"latest_commit_sha":null,"homepage":"http://ronit.is-a.dev/Baileys/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"WhiskeySockets/Baileys","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamrony777.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-20T12:13:16.000Z","updated_at":"2025-01-06T10:25:17.000Z","dependencies_parsed_at":"2023-10-11T19:42:27.518Z","dependency_job_id":null,"html_url":"https://github.com/iamrony777/Baileys","commit_stats":null,"previous_names":["iamrony777/baileys"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamrony777%2FBaileys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamrony777%2FBaileys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamrony777%2FBaileys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamrony777%2FBaileys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamrony777","download_url":"https://codeload.github.com/iamrony777/Baileys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234695507,"owners_count":18872992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["baileys","baileys-bot","baileys-lib","baileys-md","bot","mongodb","mongodb-database","redis","whatsapp","whatsapp-api","whatsapp-bot"],"created_at":"2024-09-24T13:13:46.928Z","updated_at":"2025-09-30T03:30:33.140Z","avatar_url":"https://github.com/iamrony777.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align='center'\u003e\u003cimg alt=\"Baileys logo\" src=\"https://raw.githubusercontent.com/WhiskeySockets/Baileys/refs/heads/master/Media/logo.png\" height=\"75\"/\u003e\u003c/h1\u003e\n\n\n## About this Fork\nThe original repository was removed by its author and later taken over by [WhiskeySockets](https://github.com/WhiskeySockets). This current fork is based on that. I've only made additions such as custom stores for storing authentication, messages, etc., and merged a few pull requests. That's all.\n\n\n**If you encounter any issues after using this fork or any part of it, I recommend creating a new issue here rather than on WhiskeySocket's Discord server. AND EXPECT BUGS, LOTS OF BUGS (THIS IS UNSTABLE ASF)**\n\n[![NPM Version](https://img.shields.io/npm/v/%40iamrony777%2Fbaileys?style=for-the-badge\u0026logo=npm\u0026label=BAILEYS\u0026color=%2325D366)\n](https://www.npmjs.com/package/@iamrony777/baileys)\n\n[![Static Badge](https://img.shields.io/badge/READ-DOCS-d052d9?style=for-the-badge\u0026logo=readthedocs\u0026labelColor=white)](https://ronit.is-a.dev/Baileys/)\n\n\n## Installation\n\nCheck `.env.example` first to setup databases\n\n\n```bash\nyarn install @iamrony777/baileys\n```\nor\n```bash\nyarn github:iamrony777/Baileys ## Directly from github repo\n```\n\nThen import your code using:\n``` ts\nimport makeWASocket, { ... } from '@iamrony777/baileys'\n```\n\n\n## Connecting multi device (recommended)\n\n### **I recommend to use Redis for storing auth data (as it is the fastest) and Mongo for storing chats, messages**\n\nWhatsApp provides a multi-device API that allows Baileys to be authenticated as a second WhatsApp client by scanning a QR code with WhatsApp on your phone.\n\n``` ts\nimport { MongoClient } from \"mongodb\";\nimport makeWASocket, {\n  DisconnectReason,\n  makeCacheableSignalKeyStore,\n  makeMongoStore,\n  useMongoDBAuthState,\n} from \"@iamrony777/baileys\";\nimport { Boom } from \"@hapi/boom\";\nimport \"dotenv/config\";\n\nasync function connectToWhatsApp() {\n  // MongoDB setup\n  const mongo = new MongoClient(process.env.MONGODB_URL!, {\n    socketTimeoutMS: 1_00_000,\n    connectTimeoutMS: 1_00_000,\n    waitQueueTimeoutMS: 1_00_000,\n  });\n  const authCollection = mongo.db(\"wpsessions\").collection(\"auth\");\n  const { state, saveCreds } = await useMongoDBAuthState(authCollection);\n  const store = makeMongoStore({ db: mongo.db(\"wpsessions\"), autoDeleteStatusMessage: true });\n\n  const sock = makeWASocket({\n    auth: {\n      creds: state.creds,\n      /** caching makes the store faster to send/recv messages */\n      keys: makeCacheableSignalKeyStore(state.keys),\n    },\n\n    // can provide additional config here\n    printQRInTerminal: true,\n  });\n\n  // listen on events and update database\n  store.bind(sock.ev);\n\n  sock.ev.on(\"connection.update\", async (update) =\u003e {\n    const { connection, lastDisconnect } = update;\n    if (connection === \"close\") {\n      const shouldReconnect =\n        (lastDisconnect?.error as Boom)?.output?.statusCode !==\n        DisconnectReason.loggedOut;\n      console.log(\n        \"connection closed due to \",\n        lastDisconnect?.error,\n        \", reconnecting \",\n        shouldReconnect\n      );\n      // reconnect if not logged out\n      if (shouldReconnect) {\n        await mongo.close();\n        connectToWhatsApp();\n      }\n    } else if (connection === \"open\") {\n      console.log(\"opened connection\");\n      await sock.sendMessage(\n        sock.user?.id!,\n        {\n          text: \"Connected!\",\n        },\n        { ephemeralExpiration: 1 * 60 }\n      );\n    }\n  });\n\n  sock.ev.on(\"messages.upsert\", async (m) =\u003e {\n    console.log(JSON.stringify(m, undefined, 2));\n\n    // if message type is notify and not a protocol message\n    if (\n      m.type === \"notify\" \u0026\u0026\n      !m.messages[0].message?.hasOwnProperty(\"protocolMessage\")\n    ) {\n      console.log(\"replying to\", m.messages[0].key.remoteJid);\n\n      // await sock.sendMessage(m.messages[0].key.remoteJid!, {\n      //   text: \"Hello there!\",\n      // });\n    }\n  });\n\n  sock.ev.on(\"creds.update\", async () =\u003e {\n    await saveCreds();\n  });\n}\n// run in main file\nconnectToWhatsApp();\n\n```\n\nIf the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in!\n\n**Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal.\n\n**Note:** the code to support the legacy version of WA Web (pre multi-device) has been removed in v5. Only the standard multi-device connection is now supported. This is done as WA seems to have completely dropped support for the legacy version.\n\n\n**Note:** I didn't add the search-by-contact-hash [implementation by purpshell](https://github.com/WhiskeySockets/Baileys/blob/ce325d11828b6f32584b39e7e427aa47b0ee555d/src/Store/make-in-memory-store.ts#L177-L181)  \n\n## Custom funtions added to this package\n\n### 1. `store?.getContactInfo(jid: string, socket: typeof makeWASocket)`\n## Configuring the Connection\n\n```typescript\nif (events[\"contacts.update\"]) {\n  for (const update of events[\"contacts.update\"]) {\n    if (update.imgUrl === \"changed\") { // getting \n      const contact = await store?.getContactInfo(update.id!, sock);\n      console.log(\n        `contact ${contact?.name} ${contact?.id} has a new profile pic: ${contact?.imgUrl}`\n      );\n    }\n  }\n}\n```\n\n\n\n\n## Everything besides store and auth connectors are same as the original repo.\n\n# [Read Official Docs](https://github.com/WhiskeySockets/Baileys?tab=readme-ov-file#baileys---typescriptjavascript-whatsapp-web-api)\n\n![NPM Downloads](https://img.shields.io/npm/dw/%40iamrony777%2Fbaileys?label=npm\u0026color=%23CB3837)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/iamrony777/baileys)\n\n\nThe maintainers of Baileys do not in any way condone the use of this application in practices that violate the Terms of Service of WhatsApp. The maintainers of this application call upon the personal responsibility of its users to use this application in a fair way, as it is intended to be used.\nUse at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.\n\n- Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**. \n- Not running Selenium or Chromium saves you like **half a gig** of ram :/ \n- Baileys supports interacting with the multi-device \u0026 web versions of WhatsApp.\n- Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Also, thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation.\n\n\u003e [!IMPORTANT]\n\u003e The original repository had to be removed by the original author - we now continue development in this repository here.\nThis is the only official repository and is maintained by the community.\n\u003e **Join the Discord [here](https://discord.gg/WeJM5FP9GG)**\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamrony777%2Fbaileys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamrony777%2Fbaileys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamrony777%2Fbaileys/lists"}