{"id":15285598,"url":"https://github.com/fm1randa/yagami","last_synced_at":"2025-04-13T02:30:33.358Z","repository":{"id":65301787,"uuid":"567984979","full_name":"fm1randa/yagami","owner":"fm1randa","description":"A whatsapp-web.js client abstraction that provides an easy way to run commands 🤖","archived":false,"fork":false,"pushed_at":"2023-11-01T01:15:47.000Z","size":268,"stargazers_count":4,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T21:50:10.259Z","etag":null,"topics":["automation","bot","whatsapp","whatsapp-bot","whatsapp-web","whatsapp-web-js"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/wwebjs-yagami","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fm1randa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-19T04:34:41.000Z","updated_at":"2024-01-03T06:07:44.000Z","dependencies_parsed_at":"2023-02-10T12:45:23.800Z","dependency_job_id":null,"html_url":"https://github.com/fm1randa/yagami","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fm1randa%2Fyagami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fm1randa%2Fyagami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fm1randa%2Fyagami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fm1randa%2Fyagami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fm1randa","download_url":"https://codeload.github.com/fm1randa/yagami/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657796,"owners_count":21140841,"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":["automation","bot","whatsapp","whatsapp-bot","whatsapp-web","whatsapp-web-js"],"created_at":"2024-09-30T15:06:37.053Z","updated_at":"2025-04-13T02:30:33.335Z","avatar_url":"https://github.com/fm1randa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 Yagami\n\n- [🤖 Yagami](#-yagami)\n  - [📝 Description](#-description)\n  - [💡 Usage](#-usage)\n    - [⬆️ Install](#️-install)\n    - [🔎 Example](#-example)\n  - [👾 Clients](#-clients)\n  - [🕹 Commands](#-commands)\n  - [⚙️ Environment variables](#️-environment-variables)\n  - [📦 Main dependencies](#-main-dependencies)\n    - [🎁 whatsapp-web.js](#-whatsapp-webjs)\n    - [🖥 winston](#-winston)\n  - [🗃 Database](#-database)\n    - [📂 /app/collections](#-appcollections)\n    - [📂 /app/models](#-appmodels)\n  - [🎫 Session](#-session)\n\n## 📝 Description\n\n**Yagami** is a Whatsapp client for command execution via message.\n\n## 💡 Usage\n\n### ⬆️ Install\n\n```bash\nnpm install wwebjs-yagami\n```\n\n### 🔎 Example\n\n```ts\nimport { YagamiClient, connectToDatabase } from 'wwebjs-yagami';\nimport commands from './commands';\nasync function main() {\n  const isServer = process.env.SERVER === 'true';\n\n  const { store } = await connectToDatabase();\n  const authStrategy = new RemoteAuth({\n    clientId: process.env.CLIENT_ID,\n    store,\n    backupSyncIntervalMs: 5 * 60 * 1000\n  });\n\n  const clientOptions: YagamiOptions = {\n    handleSignups: true,\n    authStrategy,\n    puppeteer: {\n      headless: true,\n      [isServer \u0026\u0026 'executablePath']: '/usr/bin/chromium-browser',\n      [isServer \u0026\u0026 'args']: ['--no-sandbox']\n    }\n  };\n\n  const client = new YagamiClient(commands, clientOptions);\n\n  start();\n\n  function start() {\n    client.init();\n  }\n}\nmain();\n```\n\nObs:\n\n**🚨 You must import `connectToDatabase` and call that function before instantiating Yagami Client.**\n\nSee [commands.md](commands.md) for more info about `commands`.\n\nAfter running `npm start` or `npm run compile` (build + start), you'll see that in the terminal:\n\n\u003cimg width=\"555\" alt=\"image\" src=\"https://user-images.githubusercontent.com/35941797/202930336-2c235b51-b8df-4e06-a2cd-09d94a5b7639.png\"\u003e\n\n## 👾 Clients\n\nIt's possible to have many concurrent clients. In other words, you can manage more than one bot simultaneously with one Node instance.\n\nTo do so, it's necessary to instantiate different objects of `YagamiClient`, in that way:\n\n```ts\nconst foo = new YagamiClient(commandsFoo, clientOptionsFoo);\nconst bar = new YagamiClient(commandsBar, clientOptionsBar);\nstart();\n\nfunction start() {\n  foo.init();\n  bar.init();\n...\n```\n\n## 🕹 Commands\n\nSee [commands README](commands.md).\n\n## ⚙️ Environment variables\n\nSome environment variables are necessary. You must create a `.env` file at the project root and follow this pattern:\n\n```dockerfile\nSERVER=false # is running in a server?\nMONGO_URI=\"\" # mongo connection string\nCLIENT_ID=\"\" # ID that will represent a unique session at the database\n```\n\n## 📦 Main dependencies\n\n### 🎁 [whatsapp-web.js](https://github.com/pedroslopez/whatsapp-web.js)\n\nIt's the main library that makes all the magic. It provides a helpful API with Whatsapp Web.\n\nThe [qrcode-terminal](https://github.com/gtanner/qrcode-terminal) module allows the QR Code mirroring from the Whatsapp Web page to the terminal.\n\n### 🖥 [winston](https://github.com/winstonjs/winston)\n\nIt's the one responsible for standardization logs. You may use the helper [logger](src/helpers/logger.ts) instead of `console.log`.\n\n## 🗃 Database\n\nThe Yagami Client, through [mongoose](https://github.com/Automattic/mongoose), uses Mongo's non-relational database to store some entities such as:\n\n- Users\n- Groups\n- [Sessions](#session)\n\nYou find the DB logic in the `src/app` directory.\n\n### 📂 /app/collections\n\nA collection provides methods to maintain a database entity. In other words, you can create, update, delete and read a database entity.\n\n### 📂 /app/models\n\nA estrutura de dados das entidades `User` e `Group` do banco é representada nas classes contidas nessa pasta.\n\n`User` and `Group`'s database entities are represented by the classes contained in that directory.\n\n## 🎫 Session\n\nYou can use any phone number with Yagami Client. To do so, it is used a session stored in the database, for avoiding scanning the QR Code every execution. It is done through the `whatsapp-web.js` auth strategy, **Remote Auth**.\n\nEach session is identified by the [environment variable](#environment-variables) `CLIENT_ID`. For each new ID, two collections are created in the Mongo database:\n\n- `whatsapp-RemoteAuth-\u003cCLIENT_ID\u003e.chunks`\n\n- `whatsapp-RemoteAuth-\u003cCLIENT_ID\u003e.files`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffm1randa%2Fyagami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffm1randa%2Fyagami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffm1randa%2Fyagami/lists"}