├── .all-contributorsrc ├── .eslintrc.js ├── .github ├── FUNDING.yml └── workflows │ └── node.js.yml ├── .gitignore ├── CHANGELOG.md ├── Dockerfile ├── LICENSE.md ├── README.md ├── app.json ├── downloads └── .placeholder ├── heroku.yml ├── locales ├── en.json └── id.json ├── package.json ├── sessions └── krypton-sessions.json ├── src ├── command │ ├── add.ts │ ├── clearall.ts │ ├── demote.ts │ ├── fakereply.ts │ ├── gdrive.ts │ ├── gmium.ts │ ├── help.ts │ ├── hidetag.ts │ ├── id.ts │ ├── kick.ts │ ├── lang.ts │ ├── notes.ts │ ├── nulis.ts │ ├── nulis2.ts │ ├── nulis3.ts │ ├── paste.ts │ ├── ping.ts │ ├── pmium.ts │ ├── promote.ts │ ├── report.ts │ ├── restart.ts │ ├── siaran.ts │ ├── slap.ts │ ├── sticker.ts │ └── update.ts ├── include │ ├── db.ts │ └── locale.ts ├── krypton.ts └── utils │ ├── color.ts │ ├── db.ts │ ├── fetcher.ts │ ├── functions.ts │ ├── greeting.ts │ ├── locale.ts │ └── web.ts ├── start.js ├── tsconfig.json └── views ├── css └── style.css ├── index.ejs └── js └── main.js /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "Kry9toN", 10 | "name": "Dhimas Bagus Prayoga", 11 | "avatar_url": "https://avatars1.githubusercontent.com/u/44697929?v=4", 12 | "profile": "http://kry9ton.tech", 13 | "contributions": [ 14 | "code" 15 | ] 16 | }, 17 | { 18 | "login": "rzlamrr", 19 | "name": "dαvιѕтα", 20 | "avatar_url": "https://avatars3.githubusercontent.com/u/46296998?v=4", 21 | "profile": "http://rzlamrr.github.io", 22 | "contributions": [ 23 | "bug" 24 | ] 25 | } 26 | ], 27 | "contributorsPerLine": 7, 28 | "projectName": "KryPtoN-WhatsApp-Bot", 29 | "projectOwner": "Kry9toN", 30 | "repoType": "github", 31 | "repoHost": "https://github.com", 32 | "skipCi": true 33 | } 34 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | commonjs: true, 4 | es6: true, 5 | node: true 6 | }, 7 | extends: [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended" 11 | ], 12 | globals: { 13 | Atomics: 'readonly', 14 | SharedArrayBuffer: 'readonly' 15 | }, 16 | parser: '@typescript-eslint/parser', 17 | parserOptions: { 18 | ecmaVersion: 2018 19 | }, 20 | rules: { 21 | eqeqeq: 0, 22 | indent: [2, 4], 23 | 'no-var': 2, 24 | 'no-unused-vars': 1, 25 | 'no-unused-expressions': 0, 26 | 'no-self-assign': 0, 27 | 'no-undef': 0, 28 | 'no-case-declarations': 0, 29 | 'prefer-promise-reject-errors': 1, 30 | 'object-property-newline': 0, 31 | 'no-useless-escape': 0 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [kry9ton]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: KryPtoN Bot CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | schedule: 12 | - cron: '0 17 * * *' 13 | 14 | jobs: 15 | build: 16 | 17 | runs-on: ubuntu-latest 18 | 19 | strategy: 20 | matrix: 21 | node-version: [10.x, 12.x, 14.x, 15.x] 22 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Use Node.js ${{ matrix.node-version }} 27 | uses: actions/setup-node@v1 28 | with: 29 | node-version: ${{ matrix.node-version }} 30 | - run: npm install 31 | - run: npm run debug 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | debug.log 4 | premium.js 5 | quotemsg.js 6 | lib/quran.js 7 | util/flat.json 8 | util/getScreenshot.js 9 | utils/canvas.js 10 | utils/flat.json 11 | utils/getScreenshot.js 12 | .node-persist 13 | *.code-workspace 14 | lib/instaStory.js 15 | lib/jiwa.js 16 | package-lock.json 17 | .env 18 | dist 19 | .cache 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### Changelog 2 | 3 | All notable changes to this project will be documented in this file. Dates are displayed in UTC. 4 | 5 | Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). 6 | 7 | #### [v1.7.9](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/compare/v1.7.9...v1.7.9) 8 | 9 | ### [v1.7.9](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/compare/v0.4.2...v1.7.9) 10 | 11 | > 29 January 2021 12 | 13 | - migrate to typescript [`0b139e3`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/0b139e3db822e2d298d4a0d9b25c263f9c4b1a42) 14 | - Add LICENSE [`13e292e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/13e292ecc21649508d86e0c5e8d2a079a53f288c) 15 | - add support web api [`0a27fe3`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/0a27fe3d914dae9d0addd40e0983f231b07e3567) 16 | - clean up source [`4c3e31c`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/4c3e31cd65116fe6771034fd6fbc484add34c7c2) 17 | - make strong type for now [`2788c97`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/2788c97122d966e68425150de2c561d3115130e1) 18 | - regen package.json [`ba6c9b1`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ba6c9b1b0cf263c8c1c8d2a52a31a32372fc1304) 19 | - add gmium [`9f07e40`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/9f07e401d6e82b3e7e591d6d9e3d1c3a81345381) 20 | - add sticker [`ff4be49`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ff4be49a5b5443d6d1d54350ff5d7ae1f13305a6) 21 | - add logging on web [`ffc9c72`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ffc9c72368f9193732f109cca9ad446a73f9a826) 22 | - add animation if log empty [`c8b7c4b`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/c8b7c4bf9f1c3ce82a760c89019ac0400bdfb913) 23 | - add notes [`0eb6234`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/0eb62340d113ae53a87d5fcbfd37b5111c13d9be) 24 | - now promote and etc can use reply/quoted [`a25fdf9`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/a25fdf92659f17d3128a0e44564c7ad8b21f84c6) 25 | - fix sticker and cooldown only not premium [`6f81a4f`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/6f81a4fa9fbbc126480c96416eed85c6caac7c10) 26 | - fix cooldown detection [`46312be`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/46312bea2ec4a65a636e32c072721de4b5609f17) 27 | - initial for database connections [`b84e10e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b84e10e46f3bd912cd8aabe021168abbe24d7365) 28 | - add initial database [`426e64e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/426e64e555892c1bda51aecdf4901400b0457192) 29 | - now cat scan QR on web [`709230e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/709230e033b43d9609cdd76227df224afb1fb321) 30 | - add siaran and improve sticker [`a98d6df`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/a98d6df7f69b971d0cbe232348f9a144a47426e8) 31 | - add loging [`c215108`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/c21510871687ffe38d77938e56e9644597f740bf) 32 | - make nice to look [`bf280dc`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/bf280dccfbc103d05c7dcf63c2105d072e838bd7) 33 | - add nulis3 and optimise [`706a5aa`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/706a5aad12cdcbd1550406c011033961600e506e) 34 | - cleanup docker and change to ubuntu focal docker [`e57055a`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/e57055a48b501415942ee4a7dbf2ede00f67829a) 35 | - try add sticker color background [`1b429c5`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/1b429c59f3272cfaa518d9f05b9fb94f709bf3ce) 36 | - fix sticker and dialog [`f9c4930`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/f9c493043a82de8f8079429edd7826b0a122439f) 37 | - add id [`b435748`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b435748b8f3afb8069f86b1816ceb3e4dc99a83b) 38 | - add fake reply [`208f91e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/208f91ec11a49fed1cab39db80acb4fd08bc3b3b) 39 | - add 2 device conditions [`432b049`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/432b049628536631dcdd88c4e5b1de6bcc7cb67e) 40 | - fix notes amd add dotenv [`057e1b7`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/057e1b7c5ab07818813fee9d0b4e5009baebdd6c) 41 | - add durations [`efceb97`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/efceb97c6258e586e02a8d1b8b11722d44f69b73) 42 | - Premium changed [`281cb8e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/281cb8ea56eefc608a85782498fcf0a08d623a11) 43 | - add method name [`a87156c`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/a87156c4b85309efa647583d9c67286345ccc6ce) 44 | - clean up and fix spam log [`a561262`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/a561262dda6ab25a20f553fbe2fbc3519fe54645) 45 | - fix notes [`1adb1c5`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/1adb1c5c10079a112e2435c2816f1e0716330f32) 46 | - fix delay on progress [`b30c508`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b30c508cb344004994899bbda68ff41d442c7ff6) 47 | - Increase id length [`4e4977f`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/4e4977f9d886e610a8af4b0e0a9527ed99554ac3) 48 | - regen for new bot client [`97d56ce`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/97d56ce7ae382e6d698751292f1944dece9b5a2d) 49 | - revert if on sticker and siaran [`94c4b4d`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/94c4b4dc62321a85b80fcce1bbd2c481cd8f4567) 50 | - fix dialog [`e577ad9`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/e577ad9461aa29c31cb1c36fe80cf31bbdea0cef) 51 | - fakereply with split [`4ed0531`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/4ed0531e3b47891bf12b2810c41bd1a4f865d364) 52 | - Update sticker.js [`541c410`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/541c41022d46f38b2829494c1c900e4492c1578c) 53 | - swict to buffer [`03412b0`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/03412b0d39e9ec7c9ee2c6d0c00507dc28479cda) 54 | - Fix ran undefined [`48bcd3d`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/48bcd3d20a9757fbbdd7424d08f44224a8ff16c5) 55 | - fix is owner method [`2be48fe`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/2be48feb5d376525902db72ac758d7aa013e8f8c) 56 | - change to web proses [`d4b843c`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/d4b843c1d30f1882f0565865c0259941d605f9a5) 57 | - add eslint command [`f28df79`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/f28df7991359f106f45e98193e864a89ae17afef) 58 | - Try to fix missing flag [`831bd51`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/831bd5119e650786dd39406122f4ad4fc2920d7a) 59 | - add fluent-ffmpeg [`4593f22`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/4593f224f52c36ad041eb46acc2879a70b017153) 60 | - improve fakereply [`c40bf07`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/c40bf0766e9a4d95a26de85d239d83f2c90fc808) 61 | - fix error on web view [`6505191`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/65051917bfd714bb99f40622dddf8df28d2d0155) 62 | - ignores .cache [`b742c1a`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b742c1aea12383267c00671b4b086ae3c53d6da2) 63 | - Fix missing media [`6115e05`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/6115e050703b7b88648cf8994cbb367a608ff301) 64 | - Release 1.7.9 [`079b077`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/079b0771b2f160b9a1078a88827bfeae26faff7f) 65 | - Fix missing req [`8bca045`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/8bca045d053a4e4594d5ef63ff4fe2e52a77d6bb) 66 | - change port on heroku to [`0d7dd97`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/0d7dd9745d6a54a94090e651a89d987305c920d3) 67 | - Update format id [`ca040d2`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ca040d2420d7dc15bea1240cb4a79a98dd2a2c03) 68 | - fix reply on gmium [`d7635dc`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/d7635dc7d8bbedc3786cd97118dbd37c25dbe9c6) 69 | - Add one break line on dialog [`1c957a3`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/1c957a3c858cc6d4b4fb8aefbf557a48b48d8a16) 70 | - Update dialog on slow mode [`b055dd9`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b055dd91966bab1c4d21eed43c18c1d42c4af943) 71 | - fix typo [`17a128e`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/17a128e4c26c3c6147c157f74a701f8d5a9679fe) 72 | - Add condition isOwner [`d7d06ba`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/d7d06bab51feb40615d5783b977ea16b9ff01bb0) 73 | - fix missing git, npm, nodejs [`54e9338`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/54e93386e9b2efd75a203c91161a154291a28283) 74 | - fix interative insalations [`471074d`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/471074d70b7a97985f40f0d94d1b634e35f37e77) 75 | - fix typo on docker [`77b4fe9`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/77b4fe9f8fb4ab228e8f914482e452878985b35c) 76 | - try add libwebp on docker [`92f7938`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/92f7938acb79057655737af3b6626ea5cf25a5f9) 77 | - Anu [`04c2ee6`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/04c2ee63abad6c16cf73e6e4fee9acbc109b6c38) 78 | - add owner on notes [`f0aa790`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/f0aa7905fa416f5a41144c55b0150dcc13d21d12) 79 | - Add owner [`4f5c680`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/4f5c680364f20075c496d24f63c7d6d4f4495a05) 80 | - Remove duplicate client [`814d975`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/814d975a900ba3fd8cc7f58308faf8410adbc2b8) 81 | - use spesifik version for module wa [`75b6a04`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/75b6a0471a80c53482e7eaa5625c15f778e6ca98) 82 | - missing fs in sticker [`f807b2c`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/f807b2c70d53baa8019d55c0eacd65014b7aeb3e) 83 | - delete copy sessions [`dd5c355`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/dd5c35590c6602fa3c3ae12fc9ce43d25164a66b) 84 | - Rename LICENSE to LICENSE.md [`d0337bc`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/d0337bcacd957ce6bebb445afbd4ac59f64819f8) 85 | 86 | #### [v0.4.2](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/compare/v0.1.0...v0.4.2) 87 | 88 | > 19 January 2021 89 | 90 | - add new fiture [`2631cca`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/2631cca30fdb1fe670bd8e2bf98109ae2e1625ad) 91 | - add cfonts and make beautifull console log [`cb428ce`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/cb428ce7c22c07648feec23d33c3e71c0c140c4b) 92 | - update changelog and readme [`64e1b95`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/64e1b95ccebabeacfbb609fe684155b841b06c7e) 93 | - Release 0.4.2 [`b5570be`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/b5570be5494711c7a3c5738b2891f8192f3fe96f) 94 | 95 | #### [v0.1.0](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/compare/v0.0.1...v0.1.0) 96 | 97 | > 18 January 2021 98 | 99 | - refactor variable and initial welcome image [`ce6c76d`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ce6c76d1276069786c9ee63a68498c43bc6708fd) 100 | - fix welcome image and improve logging [`ca5137f`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ca5137f2d04ff05f4f696ed96c01cb42278406ce) 101 | - add command and optimize [`276ac13`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/276ac137a88f81fa9ad723d46efb8e1f2ba18ca2) 102 | - initial greeting [`536f58a`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/536f58a7d996286f35da8c2e7e4928ebc53314cd) 103 | - add log every receive message [`092bb88`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/092bb881c48bedf9fbb9287007806ff33112eb2d) 104 | - add clearall [`c096011`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/c0960113bd1f14dc1c85c2421d18e698c77009ae) 105 | - initial changelog .md [`0464b09`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/0464b09f2bef63362f971715e5d5ca6814256811) 106 | - add release-it packages [`ad4b5cf`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/ad4b5cfd111c0b80805d43451147860742f5058f) 107 | - Release 0.1.0 [`edd9929`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/edd9929f2f1672f6981eff466c2c9725cb9d7941) 108 | 109 | #### v0.0.1 110 | 111 | > 16 January 2021 112 | 113 | - initial new krypton WA bot [`47ea7b8`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/47ea7b81126c52c81559349ac8064204813aa2e3) 114 | - move to indonesian language and make method ping [`9473942`](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/commit/94739426321ee9017d247e23ad98d7355e3063d7) 115 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM kry9ton/wabot-image:latest 2 | 3 | # 4 | # Clone repo and prepare working directory 5 | # 6 | RUN git clone -b master https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot /home/wabot 7 | WORKDIR /home/wabot 8 | 9 | RUN npm i 10 | 11 | CMD ["npm", "start"] 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | # KryPtoN Whatsapp Bot 4 | [![Version](https://img.shields.io/badge/version%20K--wa%20Bot-v0.1.0-brightgreen)](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/releases) 5 | [![Github Badge](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/actions/workflows/node.js.yml/badge.svg)](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/actions) 6 | [![DeepScan grade](https://deepscan.io/api/teams/11540/projects/15621/branches/315271/badge/grade.svg?token=a1fa0980263b30233c0ddf1e9c3ed778290db2ee)](https://deepscan.io/dashboard#view=project&tid=11540&pid=15621&bid=315271) 7 | 8 | 9 | [![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) 10 | 11 | 12 | [![Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/tree/master) 13 | 14 |
15 | 16 | ## Features 17 | 18 | | Sticker Creator| Feature | 19 | | :------------: | :---------------------------------------------: | 20 | | ✅ | Send Photo with Caption | 21 | | ✅ | Reply A Photo | 22 | | ✅ | Image Url | 23 | | ✅ | Animated sticker using giphy url | 24 | | ✅ | sticker with no background | 25 | | WIP | sticker meme | 26 | 27 | | Downloader | Feature | 28 | | :------------: | :---------------------------------------------: | 29 | | ✅ | Tiktok Downloader (No WM & WM) | 30 | | ✅ | Twitter Video Downloader | 31 | | ✅ | Facebook Video Downloader (SD & HD) | 32 | | BUG | Instagram Video Downloader | 33 | | ✅ | Youtube MP3 Downloader | 34 | | ✅ | Youtube MP4 Downloader | 35 | | ✅ | Mirroring download to gdrive | 36 | 37 | | Edukasi | Feature | 38 | | :------------: | :---------------------------------------------: | 39 | | ✅ | Translate text (quote only) | 40 | | ✅ | Brainly search engine | 41 | | ✅ | Wiki search engine | 42 | 43 | | Other | Feature | 44 | | :------------: | :---------------------------------------------: | 45 | | ✅ | Create Custom meme (top text & bottom text) | 46 | | ✅ | check data on the spread of Covid-19 in certain locations| 47 | | ✅ | Check Shipping info (indonesia only) | 48 | | ✅ | Anti Spam | 49 | | ✅ | Multi Language | 50 | 51 | | Grup Only | Feature | 52 | | :------------: | :---------------------------------------------: | 53 | | ✅ | Promote User | 54 | | ✅ | Demote User | 55 | | ✅ | Kick User | 56 | | ✅ | Delete bot message | 57 | | ✅ | Mention All User | 58 | | ✅ | Global Banned | 59 | | ✅ | Filters Message | 60 | 61 | #### Suport Postgrasql database 62 | 63 | ## To-Do 64 | - Add More Feature 65 | - More refactoring 66 | 67 | --- 68 | 69 | ## Getting Started 70 | 71 | This project support nodejs vesions 10,12,14,15 72 | 73 | ### Install 74 | Clone this project 75 | 76 | ```bash 77 | > git clone https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot 78 | > cd KryPtoN-WhatsApp-Bot 79 | ``` 80 | 81 | Install the dependencies: 82 | 83 | ```bash 84 | > npm install 85 | ``` 86 | 87 | ### Usage 88 | 1. run the Whatsapp bot 89 | 90 | ```bash 91 | > npm start 92 | ``` 93 | 94 | after running it you need to scan the qr 95 | 96 | ## Before deoloy heroku 97 | 98 | You must run this bot on your PC/laptop to generate a session 99 | after being authorized, in your folder there will be a file called 100 | ``` 101 | session.data.json 102 | ``` 103 | please copy on the `sessions` folder with the same name (don't change it) 104 | 105 | ## Troubleshooting 106 | Make sure all the necessary dependencies are installed: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md 107 | 108 | Fix Stuck on linux, install google chrome stable: 109 | ```bash 110 | > wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 111 | > sudo apt install ./google-chrome-stable_current_amd64.deb 112 | ``` 113 | 114 | ## Donate 115 | 116 | ### Buy me coffee 117 | [Saweria](https://saweria.co/donate/Kry9toN) 118 | 119 | [Paypal.me](https://www.paypal.me/KomodoOS) 120 | 121 | 122 | ## Contributors ✨ 123 | 124 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 |

Dhimas Bagus Prayoga

💻

dαvιѕтα

🐛
135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "KryPtoN WhatsApp Bot", 3 | "description": "WhatsApp Bot running on Javascript", 4 | "keywords": [ 5 | "whatsapp", 6 | "bot", 7 | "plugin", 8 | "modular", 9 | "productivity" 10 | ], 11 | "repository": "https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot", 12 | "website": "", 13 | "stack": "container", 14 | "env": { 15 | "LOGGING": { 16 | "description": "ID group for logging", 17 | "required": false 18 | }, 19 | "OWNER_PHONE": { 20 | "description": "Enter your phone number.", 21 | "required": true 22 | }, 23 | "BOT_NUMBER": { 24 | "description": "Enter bot phone number.", 25 | "required": true 26 | }, 27 | "KEY_REMOVEBG": { 28 | "description": "Enter remove.bg api key.", 29 | "required": true 30 | }, 31 | "API_KEY": { 32 | "description": "Enter api key universal mean is like api rest but use all fiture.", 33 | "required": true 34 | }, 35 | "WEB_API": { 36 | "description": "Enter initial web api for your auth.", 37 | "required": true 38 | } 39 | }, 40 | "addons": [ 41 | { 42 | "plan": "heroku-postgresql", 43 | "options": { 44 | "version": "9.5" 45 | } 46 | } 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /downloads/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kry9toN/KryPtoN-WhatsApp-Bot/5f2e08f16628b62272e7d5077a6dd1bd7360c95b/downloads/.placeholder -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | web: Dockerfile 4 | run: 5 | web: npm start 6 | -------------------------------------------------------------------------------- /locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "help": { 3 | "desc": "Show all commands and descriptions", 4 | "startDialog": "List of commands on this bot \n\nJoin the KryPtoN Bot group: https://is.gd/wa0p84\nMonitoring Bot: https://wa.kry9ton.tech\n\nPrefix: ! \n", 5 | "endDialog": "\nStill confused? type *!help * will display the use of the command", 6 | "notMatch": "The command you specified does not exist" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /locales/id.json: -------------------------------------------------------------------------------- 1 | { 2 | "bot": { 3 | "berhasil": "✅ Berhasil ✅", 4 | "tunggu": "⌛ Sedang di Prosess ⌛", 5 | "gagal": "❌ Gagal melaksanakan perintah ❌", 6 | "admin": "❌ Perintah ini hanya bisa di gunakan oleh admin group! ❌", 7 | "botAdmin": "❌ Perintah ini hanya bisa di gunakan ketika bot menjadi admin! ❌", 8 | "owner": "❌ Perintah hanya untuk owner/sudo! ❌", 9 | "premium": "❌ Perintah hanya untuk pelanggan premium! ❌", 10 | "group": "❌ Perintah ini hanya bisa di gunakan dalam group! ❌", 11 | "args": "❌ Perintah anda salah! ❌" 12 | }, 13 | "help": { 14 | "desc": "Menampilkan semua perintah dan deskripsi", 15 | "startDialog": "Daftar perintah di bot ini\n\nGabung ke group KryPtoN Bot: https://is.gd/wa0p84\nMonitoring Bot: https://wa.kry9ton.tech\n\nPrefix: !\n", 16 | "endDialog": "\nMasih bingung? ketik *!help * akan menampilkan penggunaan perintah tersebut", 17 | "notMatch": "Perintah yang anda maksut tidak ada" 18 | }, 19 | "add": { 20 | "desc": "Untuk menambahkan orang ke group dengan nomor\nPenggunaan: !add 6285xxxx", 21 | "noMentions": "Siapa yang harus aku tambahkan ?", 22 | "codeNum": "Harap pakai code negara", 23 | "errAdd": "Gagal menambahkan target, mungkin karena privasi" 24 | }, 25 | "clearall": { 26 | "desc": "Untuk benghapus semua chat _only owner_", 27 | "clearDone": "Berhasil menghapus semua chat" 28 | }, 29 | "demote": { 30 | "desc": "Untuk manghapus admin anggota group\nPenggunaan: !demote _quoted/tag_", 31 | "demoteSelf": "Aku tidak mau kau suruh untuk menurunkan jabatan diriku sendiri", 32 | "demoted": "@{user} Telah di turunkan jabatannya", 33 | "demotedBulk": "Menurunkan jabatan:\n" 34 | }, 35 | "fakeReply": { 36 | "desc": "Untuk memfitnah atau menjahili teman\nPenggunaan !fakereply _tag_||", 37 | "error": "Baca penggunaan di _!help fakereply_" 38 | }, 39 | "gdrive": { 40 | "desc": "Untuk mendownload mengupload file ke Google Drive _only owner / VIP_", 41 | "vip": "Anda bukan user VIP di bot ini", 42 | "regenToken": "Silakan regenerate token dengan cara *!gdrive auth*", 43 | "start": "Mulai Download file", 44 | "finish": "Download selesai", 45 | "gdStart": "Mulai mengupload ke Google Drive\nMungkin membutuhkan waktu yang lama, tunggu aja", 46 | "failed": "Download file gagal", 47 | "notFound": "File tidak di temukan di folder download", 48 | "failedGD": "Gagal saat mengupload file ke Google Drive", 49 | "doneGD": "Berhasil mengupload file\n🗒️ {nameFile}\nLink: {link}", 50 | "secretErr": "Error saat loading client secret file: {err}", 51 | "tokenErr": "Gagal mengakses token: {err}", 52 | "tokenSuc": "Token refresh berhasil di buat", 53 | "authUri": "Buka url ini untuk mendapat kan code auth: {url}\n\nKetik: !gdrive auth token untuk confirmasi", 54 | "apiErr": "Api Google Drive error: {err}", 55 | "gdFile": "Gdrive list file:\n", 56 | "gdNoFile": "File tidak ditemukan.", 57 | "gdDirErr": "Gagal saat membuat folder di Google Drive", 58 | "gdDriSuc": "Berhasil memebuat folder\n📂️ {nameFolder} {link}" 59 | }, 60 | "gmium": { 61 | "desc": "Untuk mengelola member premium group _only owner_", 62 | "startDialog": "📝 Daftar *Premium* di bot ini\n", 63 | "lifetime": "*Lifetime*: ", 64 | "sign": "*Bersangkutan*: ", 65 | "start": "*Mulai*: ", 66 | "noMember": "- Belum ada member", 67 | "errorDb": "Error saat mengambil database" 68 | }, 69 | "hidetag": { 70 | "desc": "Untuk mengetag semua orang tanpa @\nPenggunaan !hidetag _text_" 71 | }, 72 | "id": { 73 | "desc": "Untuk menampilkan id group/user\nPenggunaan: !id", 74 | "gId": "*ID* kamu : {uid}\nGroup *ID* : {gid}", 75 | "uId": "*ID* kamu : {uid}" 76 | }, 77 | "kick": { 78 | "desc": "Untuk mengeluarkan angota di group\nPenggunaan: !kick _quoted/tag_", 79 | "noTag": "Tag target yang ingin di tendang!", 80 | "self": "Aku di tulis dengan otak, jadi jangan pikir aku tidak mengerti untuk meng-kick diriku sendiri", 81 | "confirmed": "Perintah di terima, mengeluarkan :\n", 82 | "confirmedMention": "Perintah di terima, mengeluarkan : @{mentioned}" 83 | }, 84 | "lang": { 85 | "desc": "Untuk menyeting bahasa di group/pm\nPenggunaan: !lang set ", 86 | "setup": "Bahasa berhasil di setup", 87 | "update": "Bahasa berhasil di update", 88 | "notFound": "Code bahasa yang anda masukan tidak terdaftar\nBahasa yang terdaftar saat ini: {list}" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "krypton-whatsapp-bot", 3 | "version": "1.7.9", 4 | "private": true, 5 | "description": "KryPtoN Whatsapp Bot", 6 | "main": "krypton.js", 7 | "scripts": { 8 | "start": "node start", 9 | "compile": "tsc --build tsconfig.json", 10 | "changelog": "auto-changelog -p && git add CHANGELOG.md", 11 | "release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it", 12 | "lint": "eslint . --ignore-path .gitignore --ext .ts --cache --cache-location .cache/eslintcache", 13 | "lint:fix": "eslint . --ignore-path .gitignore --ext .ts --fix --cache --cache-location .cache/eslintcache", 14 | "debug": "tsc --build tsconfig.json && eslint . --ignore-path .gitignore --ext .ts --cache --cache-location .cache/eslintcache && jsonlint locales/*" 15 | }, 16 | "author": "KryPtoN", 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot.git" 20 | }, 21 | "keywords": [ 22 | "Whatsapp", 23 | "WhatsApp-Bot", 24 | "bot", 25 | "wabot" 26 | ], 27 | "release-it": { 28 | "github": { 29 | "release": true 30 | } 31 | }, 32 | "eslintConfig": { 33 | "ignorePatterns": "build/*/**" 34 | }, 35 | "auto-changelog": { 36 | "commitLimit": false 37 | }, 38 | "bugs": { 39 | "url": "https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/issues" 40 | }, 41 | "homepage": "https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot", 42 | "license": "SEE LICENSE IN LICENSE.md", 43 | "dependencies": { 44 | "@adiwajshing/baileys": "^3.4.1", 45 | "auto-changelog": "^2.2.1", 46 | "axios": "^0.21.1", 47 | "cfonts": "^2.9.1", 48 | "chalk": "^4.1.0", 49 | "child_process": "^1.0.2", 50 | "discord.js": "^12.5.1", 51 | "dotenv": "^8.2.0", 52 | "ejs": "^3.1.5", 53 | "express": "^4.17.1", 54 | "fluent-ffmpeg": "^2.1.2", 55 | "googleapis": "^73.0.0", 56 | "i18n": "^0.13.2", 57 | "mime-types": "^2.1.28", 58 | "moment-timezone": "^0.5.32", 59 | "node-fetch": "^2.6.1", 60 | "node-os-utils": "^1.3.2", 61 | "pg": "^8.5.1", 62 | "release-it": "^14.2.2", 63 | "remove.bg": "^1.3.0", 64 | "socket.io": "^3.1.0", 65 | "source-map-loader": "^2.0.0", 66 | "spinnies": "^0.5.1", 67 | "typescript": "^4.1.3", 68 | "wa-canvas": "git+https://github.com/Kry9toN/wa-canvas.git" 69 | }, 70 | "devDependencies": { 71 | "@types/express": "^4.17.11", 72 | "@types/fluent-ffmpeg": "^2.1.16", 73 | "@types/i18n": "^0.13.0", 74 | "@types/mime-types": "^2.1.0", 75 | "@types/node-fetch": "^2.5.8", 76 | "@types/pg": "^7.14.11", 77 | "@typescript-eslint/eslint-plugin": "^4.16.1", 78 | "@typescript-eslint/parser": "^4.16.1", 79 | "eslint": "^7.14.0", 80 | "jsonlint": "^1.6.3" 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /sessions/krypton-sessions.json: -------------------------------------------------------------------------------- 1 | { 2 | "clientID": "sRADpU3ponyB62NxtFVZkA==", 3 | "serverToken": "1@2utDt96k/2vMBRlXriJaM3GSgZsTgt5tAXOvx74E7999ZpueKV6okjaL1I5oE3sR2tkbfTVtSjNvow==", 4 | "clientToken": "oIAR6k4UJ1hygl5dw6tB2QTtKEbYAwHvFT/HTyJdlnE=", 5 | "encKey": "seJfjDWYHB30svuOBHLWQ+w/y2hK77REX2FWtu9frxw=", 6 | "macKey": "XD52TUaAnGrfoTlHRAwIlPE/a69AEvusuOgtt5G5TNw=" 7 | } -------------------------------------------------------------------------------- /src/command/add.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { color } from '../utils/color' 19 | import i18n from 'i18n' 20 | 21 | export = { 22 | name: 'add', 23 | aliases: ['ad'], 24 | cooldown: 20, 25 | description: 'add.desc', 26 | execute (client: any, chat: any, pesan: any, args: any) { 27 | if (!client.isGroup) return client.reply(pesan.error.group) 28 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 29 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 30 | if (args.length < 1) return client.reply(i18n.__('add.noMentions')) 31 | if (args[0].startsWith('08')) return client.reply(i18n.__('help.codeNum')) 32 | try { 33 | const num = `${args[0].replace(/ /g, '')}@s.whatsapp.net` 34 | client.groupAdd(client.from, [num]) 35 | } catch (e) { 36 | console.log('Error : %s', color(e, 'red')) 37 | client.reply(i18n.__('add.errAdd')) 38 | client.log(e) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/command/clearall.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import i18n from 'i18n' 19 | 20 | module.exports = { 21 | name: 'clearall', 22 | aliases: ['ca'], 23 | description: 'clearall.desc', 24 | execute (client: any, chat: any, pesan: any) { 25 | if (!client.isOwner) return client.reply(pesan.hanya.owner) 26 | const chatAll = client.chats.all() 27 | client.setMaxListeners(25) 28 | for (const chat of chatAll) { 29 | client.deleteChat(chat.jid) 30 | } 31 | client.reply(i18n.__('clearall.clearDone')) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/command/demote.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import i18n from 'i18n' 19 | 20 | module.exports = { 21 | name: 'demote', 22 | aliases: ['dm'], 23 | cooldown: 10, 24 | description: 'demote.desc', 25 | execute (client: any, chat: any, pesan: any) { 26 | if (!client.isGroup) return client.reply(pesan.error.group) 27 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 28 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 29 | if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag target yang ingin di demote!') 30 | const mentions = client.quotedId || client.mentioned 31 | let mentioned 32 | if (!Array.isArray(mentions)) { 33 | mentioned = [] 34 | mentioned.push(mentions) 35 | } else { 36 | mentioned = mentions 37 | } 38 | if (mentioned.includes(client.botNumber)) return client.reply(i18n.__('demote.demoteSelf')) 39 | if (mentioned.length > 1) { 40 | let teks = i18n.__('demote.demoteBulk') 41 | for (const _ of mentioned) { 42 | teks += `@${_.split('@')[0]}\n` 43 | } 44 | client.mentions(teks, mentioned, true) 45 | client.groupDemoteAdmin(client.from, mentioned) 46 | } else { 47 | client.mentions(i18n.__('demote.demoted', { user: mentioned[0].split('@')[0] }), mentioned, true) 48 | client.groupDemoteAdmin(client.from, mentioned) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/command/fakereply.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import i18n from 'i18n' 20 | 21 | module.exports = { 22 | name: 'fakereply', 23 | aliases: ['fr', 'fake', 'fitnah'], 24 | cooldown: 35, 25 | description: 'fakeReply.desc', 26 | execute (client: any, chat: any, pesan: any) { 27 | if (!client.isGroup) return client.reply(pesan.error.group) 28 | const arg = client.body.slice(9) 29 | const targets = arg.split('|')[1] 30 | const bot = arg.split('|')[2] 31 | if (targets == 'undefined' || bot == 'undefined') return client.reply(i18n.__('fakeReply.error')) 32 | const mentioned = chat.message.extendedTextMessage.contextInfo.mentionedJid 33 | client.sendMessage(client.from, `${bot}`, MessageType.text, { quoted: { key: { fromMe: false, participant: `${mentioned}`, ...(client.from ? { remoteJid: client.from } : {}) }, message: { conversation: `${targets}` } } }) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/command/gdrive.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import fs from 'fs' 20 | import path from 'path' 21 | // eslint-disable-next-line @typescript-eslint/no-var-requires 22 | const { google } = require('googleapis') 23 | import { term } from '../utils/functions' 24 | import mime from 'mime-types' 25 | import i18n from 'i18n' 26 | 27 | module.exports = { 28 | name: 'gdrive', 29 | aliases: ['gd'], 30 | description: 'gdrive.desc', 31 | async execute (client: any, chat: any, pesan: any, args: any) { 32 | if (!client.isOwner && !client.isSudo) return client.reply(i18n.__('gdrive.vip')) 33 | // If modifying these scopes, delete token.json. 34 | const SCOPES = ['https://www.googleapis.com/auth/drive'] 35 | // The file token.json stores the user's access and refresh tokens, and is 36 | // created automatically when the authorization flow completes for the first 37 | // time. 38 | const TOKEN_PATH = path.join(__dirname, '../../token.json') 39 | const BASE_GD = 'https://drive.google.com/uc?id={}&export=download' 40 | 41 | /** 42 | * Create an OAuth2 client with the given credentials, and then execute the 43 | * given callback function. 44 | * @param {Object} credentials The authorization client credentials. 45 | * @param {function} callback The callback to call with the authorized client. 46 | */ 47 | function authorize (credentials: any, callback: any) { 48 | // eslint-disable-next-line camelcase 49 | const { client_secret, client_id, redirect_uris } = credentials.installed 50 | const oAuth2Client = new google.auth.OAuth2( 51 | client_id, client_secret, redirect_uris[0]) 52 | 53 | // Check if we have previously stored a token. 54 | fs.readFile(TOKEN_PATH, (err: any, token: any) => { 55 | if (err) return client.reply(i18n.__('gdrive.regenToken')) 56 | oAuth2Client.setCredentials(JSON.parse(token)) 57 | callback(oAuth2Client) 58 | }) 59 | } 60 | 61 | /** 62 | * Describe with given media and metaData and upload it using google.drive.create method() 63 | */ 64 | async function uploadFile (auth: string) { 65 | const id = client.from 66 | const quoted = chat 67 | const url = args[0] 68 | client.reply(i18n.__('gdrive.start')) 69 | await term(`aria2c '${url}' --dir=$(pwd)/downloads`).then(() => { 70 | client.sendMessage(id, i18n.__('gdrive.finish'), MessageType.text, { quoted: quoted }) 71 | client.sendMessage(id, i18n.__('gdrive.gdStart'), MessageType.text, { quoted: quoted }) 72 | }).catch((err: string) => { 73 | client.log(err) 74 | client.sendMessage(id, i18n.__('gdrive.failed'), MessageType.text, { quoted: quoted }) 75 | console.log(err) 76 | }) 77 | 78 | await fs.readdir(path.join(__dirname, '../../downloads/'), async (err: any, nameFile: Array) => { 79 | if (err) return client.reply(i18n.__('gdrive.notFound')) 80 | // 'files' is an array of the files found in the directory 81 | 82 | const name = nameFile[1] 83 | const drive = google.drive({ version: 'v3', auth }) 84 | interface meta { 85 | name: string; 86 | [parent: string]: any; 87 | } 88 | const fileMetadata: meta = { 89 | name: name 90 | } 91 | if (process.env.GD_ID_DIR !== 'undefined') { 92 | fileMetadata.parent = [process.env.GD_ID_DIR] 93 | } 94 | const type = mime.lookup(path.join(__dirname, `../../downloads/${nameFile[1]}`)) 95 | const media = { 96 | mimeType: type, 97 | body: fs.createReadStream(path.join(__dirname, `../../downloads/${nameFile[1]}`)) 98 | } 99 | await drive.files.create({ 100 | resource: fileMetadata, 101 | media: media, 102 | fields: 'id, name', 103 | supportsAllDrives: true 104 | }, (err: string, file: any) => { 105 | if (err) { 106 | // Handle error 107 | console.error(err) 108 | client.log(`${err}`) 109 | client.sendMessage(id, i18n.__('gdrive.filedGD'), MessageType.text, { quoted: quoted }) 110 | } else { 111 | client.sendMessage(id, i18n.__('gdrive.doneGD', { nameFile: file.data.name, link: BASE_GD.replace(/{}/g, file.data.id) }), MessageType.text, { quoted: quoted }) 112 | term('rm -rf downloads/*') 113 | } 114 | }) 115 | }) 116 | } 117 | 118 | function listFiles (auth: string) { 119 | const drive = google.drive({ version: 'v3', auth }) 120 | drive.files.list({ 121 | pageSize: 10, 122 | fields: 'nextPageToken, files(id, name, mimeType, webViewLink, webContentLink)' 123 | }, (err: string, res: any) => { 124 | if (err) return client.reply(i18n.__('gdrive.apiErr', { err: err })) 125 | const files = res.data.files 126 | if (files.length) { 127 | let text = i18n.__('gdrive.gdFile') 128 | // eslint-disable-next-line array-callback-return 129 | files.map((file: any) => { 130 | if (file.mimeType == 'application/vnd.google-apps.folder') { 131 | const link = file.webViewLink 132 | text += `📂 *${file.name}*\nLink: ${link}\n\n` 133 | } else { 134 | const link = file.webContentLink 135 | text += `🗒️ *${file.name}*\nLink: ${link}\n\n` 136 | } 137 | }) 138 | client.reply(text) 139 | } else { 140 | client.reply(i18n.__('gdrive.gdNoFile')) 141 | } 142 | }) 143 | } 144 | 145 | /** 146 | * Describe with given media and metaData and upload it using google.drive.create method() 147 | */ 148 | function createFolder (auth: string) { 149 | client.reply(pesan.tunggu) 150 | const name = args[1] 151 | const drive = google.drive({ version: 'v3', auth }) 152 | interface meta { 153 | name: any; 154 | mimeType: string; 155 | [parent: string]: any; 156 | } 157 | const fileMetadata: meta = { 158 | name: name, 159 | mimeType: 'application/vnd.google-apps.folder' 160 | 161 | } 162 | if (process.env.GD_ID_DIR !== 'undefined') { 163 | fileMetadata.parent = [process.env.GD_ID_DIR] 164 | } 165 | drive.files.create({ 166 | resource: fileMetadata, 167 | fields: 'webViewLink, name' 168 | }, (err: string, file: any) => { 169 | if (err) { 170 | // Handle error 171 | console.error(err) 172 | client.log(`${err}`) 173 | client.reply(i18n.__('gdrive.gdDirErr')) 174 | } else { 175 | client.reply(i18n.__('gdrive.doneGD', { nameFolder: file.data.name, link: file.data.webViewLink })) 176 | } 177 | }) 178 | } 179 | 180 | if (args.length <= 1 && (client.isUrl(args[0]) || args[0].startsWith('magnet'))) { 181 | // Load client secrets from a local file. 182 | fs.readFile(path.join(__dirname, '../../credentials.json'), (err: any, content: any) => { 183 | if (err) return client.log(i18n.__('gdrive.secretErr', { err: err })) 184 | // Authorize a client with credentials, then call the Google Drive API. 185 | authorize(JSON.parse(content), uploadFile) 186 | }) 187 | } else if (args[0] == 'auth') { 188 | if (args.length == 1) { 189 | fs.readFile(path.join(__dirname, '../../credentials.json'), (err: any, content: any) => { 190 | if (err) return client.reply(i18n.__('gdrive.secretErr', { err: err })) 191 | const credentials = JSON.parse(content) 192 | // eslint-disable-next-line camelcase 193 | const { client_secret, client_id, redirect_uris } = credentials.installed 194 | const oAuth2Client = new google.auth.OAuth2( 195 | client_id, client_secret, redirect_uris[0]) 196 | // Check if we have previously stored a token. 197 | fs.readFile(TOKEN_PATH, (err: any) => { 198 | if (err) { 199 | const authUrl = oAuth2Client.generateAuthUrl({ 200 | access_type: 'offline', 201 | scope: SCOPES 202 | }) 203 | client.reply(i18n.__('gdrive.authUri', { url: authUrl })) 204 | } 205 | }) 206 | }) 207 | } else if (args.length > 1 && args[1] === 'token') { 208 | fs.readFile(path.join(__dirname, '../../credentials.json'), (err: any, content: any) => { 209 | if (err) return client.reply(i18n.__('gdrive.secretErr', { err: err })) 210 | const credentials = JSON.parse(content) 211 | // eslint-disable-next-line camelcase 212 | const { client_secret, client_id, redirect_uris } = credentials.installed 213 | const oAuth2Client = new google.auth.OAuth2( 214 | client_id, client_secret, redirect_uris[0]) 215 | const code = args[1] == 'token' ? args[2] : '' 216 | oAuth2Client.getToken(code, (err: any, token: string) => { 217 | if (err) return client.reply(i18n.__('gdrive.tokenErr', { err: err })) 218 | oAuth2Client.setCredentials(token) 219 | // Store the token to disk for later program executions 220 | fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err: any) => { 221 | if (err) return console.error(err) 222 | client.reply(i18n.__('gdrive.tokenSuc')) 223 | }) 224 | }) 225 | }) 226 | } 227 | } else if (args[0] == 'list') { 228 | // Load client secrets from a local file. 229 | fs.readFile(path.join(__dirname, '../../credentials.json'), (err: any, content: any) => { 230 | if (err) return client.log(i18n.__('gdrive.secretErr', { err: err })) 231 | // Authorize a client with credentials, then call the Google Drive API. 232 | authorize(JSON.parse(content), listFiles) 233 | }) 234 | } else if (args.length > 1 && args[0] == 'mkdir') { 235 | // Load client secrets from a local file. 236 | fs.readFile(path.join(__dirname, '../../credentials.json'), (err: any, content: any) => { 237 | if (err) return client.log(i18n.__('gdrive.secretErr', { err: err })) 238 | // Authorize a client with credentials, then call the Google Drive API. 239 | authorize(JSON.parse(content), createFolder) 240 | }) 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /src/command/gmium.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { databaseView, databaseInput } from '../utils/db' 19 | import i18n from 'i18n' 20 | 21 | module.exports = { 22 | name: 'gmium', 23 | aliases: ['gm'], 24 | description: 'gmium.desc', 25 | async execute (client: any, chat: any, pesan: any, args: any) { 26 | if (!client.isOwner && !client.isSudo) return client.reply(pesan.hanya.owner) 27 | const gid = args[1] 28 | if (args[0] === 'add') { 29 | const mentioned = chat.message.extendedTextMessage.contextInfo.mentionedJid 30 | const sign = mentioned[0] 31 | if (args[1] === 'unlimited') { 32 | if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag yang bersangkutan!') 33 | const gid = args[2] 34 | databaseInput(`INSERT INTO gmium(gid, lifetime, signature) VALUES('${gid}', 'unlimited', '${sign}')`) 35 | .then(() => { 36 | client.reply(pesan.berhasil) 37 | }).catch((err: string) => { 38 | client.reply(pesan.gagal) 39 | console.log(err) 40 | client.log(err) 41 | }) 42 | } else { 43 | databaseInput(`INSERT INTO gmium(gid, lifetime, signature) VALUES('${gid}', 'standard', '${sign}')`) 44 | .then(() => { 45 | client.reply(pesan.berhasil) 46 | }).catch((err: string) => { 47 | client.reply(pesan.gagal) 48 | console.log(err) 49 | client.log(err) 50 | }) 51 | } 52 | } else if (args[0] === 'del') { 53 | databaseInput(`DELETE FROM gmium WHERE gid = '${gid}'`) 54 | .then(() => { 55 | client.reply(pesan.berhasil) 56 | }).catch((err: string) => { 57 | client.reply(pesan.gagal) 58 | console.log(err) 59 | client.log(err) 60 | }) 61 | } else if (args.length === 0) { 62 | await databaseView('SELECT * FROM gmium') 63 | .then((result: any) => { 64 | let text = i18n.__('gmium.startDialog') 65 | const mentioned = [] 66 | if (result.length > 0) { 67 | for (let i = 0; i < result.length; i++) { 68 | const gid = result[i].gid 69 | const waktu = result[i].waktu 70 | const sign = result[i].signature 71 | mentioned.push(sign) 72 | const life = result[i].lifetime 73 | text += `${i}. *GID*: ${gid}\n` 74 | text += ` ├> ${i18n.__('gmium.lifetime')} ${life}\n` 75 | text += ` ├> ${i18n.__('gmium.sign')} @${sign.replace('@s.whatsapp.net', '')}\n` 76 | text += ` └> ${i18n.__('gmium.start')} ${waktu}\n` 77 | } 78 | client.mentions(`${text}`, mentioned, true) 79 | } else { 80 | text += i18n.__('gmium.noMember') 81 | client.reply(text) 82 | } 83 | }).catch((err: string) => { 84 | client.reply(i18n.__('gmium.errorDb')) 85 | console.log(err) 86 | client.log(err) 87 | }) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/command/help.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import i18n from 'i18n' 19 | 20 | module.exports = { 21 | name: 'help', 22 | aliases: ['h'], 23 | cooldown: 10, 24 | description: 'help.desc', 25 | execute (client: any, chat: any, pesan: any, args: any) { 26 | const commands = client.cmd.array() 27 | if (args.length == 0) { 28 | let text = i18n.__('help.startDialog') 29 | commands.forEach((cmd: any) => { 30 | text += `- *${cmd.name}* ${cmd.aliases ? `(${cmd.aliases})` : ''}\n` 31 | }) 32 | text += i18n.__('help.endDialog') 33 | return client.reply(text) 34 | } else { 35 | if (!client.cmd.has(args[0])) return client.reply(i18n.__('help.notMatch')) 36 | const code = client.cmd.get(args[0]).description 37 | const text = i18n.__(code) 38 | return client.reply(text) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/command/hidetag.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | module.exports = { 19 | name: 'hidetag', 20 | aliases: ['ht'], 21 | cooldown: 45, 22 | description: 'hidetag.desc', 23 | execute (client: any, chat: any, pesan: any) { 24 | if (!client.isGroup) return client.reply(pesan.error.group) 25 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 26 | const value = client.body.slice(9) 27 | const memberList = [] 28 | for (const member of client.groupMembers) { 29 | memberList.push(member.jid) 30 | } 31 | const options = { 32 | text: value, 33 | contextInfo: { mentionedJid: memberList }, 34 | quoted: chat 35 | } 36 | client.sendMess(client.from, options) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/command/id.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import i18n from 'i18n' 19 | 20 | module.exports = { 21 | name: 'id', 22 | cooldown: 10, 23 | description: 'id.desc', 24 | execute (client: any, chat: any, pesan: any) { 25 | const uid = client.sender 26 | if (client.isGroup) { 27 | const gid = client.groupId 28 | client.reply(i18n.__('id.gId', { uid: uid, gid: gid })) 29 | } else { 30 | client.reply(i18n.__('id.uId', { uid: uid })) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/command/kick.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import i18n from 'i18n' 19 | 20 | module.exports = { 21 | name: 'kick', 22 | aliases: ['k'], 23 | cooldown: 10, 24 | description: 'kik.desc', 25 | execute (client: any, chat: any, pesan: any) { 26 | if (!client.isGroup) return client.reply(pesan.error.group) 27 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 28 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 29 | if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply(i18n.__('kick.noTag')) 30 | const mentions = client.quotedId || client.mentioned 31 | let mentioned 32 | if (!Array.isArray(mentions)) { 33 | mentioned = [] 34 | mentioned.push(mentions) 35 | } else { 36 | mentioned = mentions 37 | } 38 | if (mentioned.includes(client.botNumber)) return client.reply(i18n.__('kick.self')) 39 | if (mentioned.length > 1) { 40 | let teks = i18n.__('kick.confirmed') 41 | for (const _ of mentioned) { 42 | teks += `@${_.split('@')[0]}\n` 43 | } 44 | client.mentions(teks, mentioned, true) 45 | client.groupRemove(client.from, mentioned) 46 | } else { 47 | client.mentions(i18n.__('kick.confirmedMention', { mentioned: mentioned[0].split('@')[0] }), mentioned, true) 48 | client.groupRemove(client.from, mentioned) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/command/lang.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { databaseView, databaseInput } from '../utils/db' 19 | import i18n from 'i18n' 20 | 21 | module.exports = { 22 | name: 'lang', 23 | cooldown: 15, 24 | description: 'lang.desc', 25 | async execute (client: any, chat: any, pesan: any, args: any) { 26 | const list: any = ['en', 'id'] 27 | if (args[0] == 'set' && list.includes(args[1])) { 28 | const lang = args[1] 29 | if (client.isGroup) { 30 | const from = client.from 31 | if (!client.isGmium) return client.reply(pesan.hanya.premium) 32 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 33 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 34 | await databaseView(`SELECT EXISTS ( SELECT id FROM locales WHERE id = '${from}' )`) 35 | .then((hasil: any) => { 36 | if (hasil[0].exists == true) { 37 | databaseInput(`UPDATE locales SET locale = '${lang}' WHERE id = '${from}'`).then(() => { 38 | client.reply(i18n.__('lang.update')) 39 | }) 40 | } else { 41 | databaseInput(`INSERT INTO locales(id, locale) VALUES('${from}' ,'${lang}')`).then(() => { 42 | client.reply(i18n.__('lang.setup')) 43 | }) 44 | } 45 | }) 46 | } else { 47 | const from = client.from 48 | if (!client.isPmium) return client.reply(pesan.hanya.premium) 49 | await databaseView(`SELECT EXISTS ( SELECT id FROM locales WHERE id = '${from}' )`) 50 | .then((hasil: any) => { 51 | if (hasil[0].exists == true) { 52 | databaseInput(`UPDATE locales SET locale = '${lang}' WHERE id = '${from}'`).then(() => { 53 | client.reply(i18n.__('lang.update')) 54 | }) 55 | } else { 56 | databaseInput(`INSERT INTO locales(id, locale) VALUES('${from}' ,'${lang}')`).then(() => { 57 | client.reply(i18n.__('lang.setup')) 58 | }) 59 | } 60 | }) 61 | } 62 | } else { 63 | client.reply(i18n.__('lang.notFound', { list: list.toString })) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/command/notes.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { databaseView, databaseInput } from '../utils/db' 19 | 20 | module.exports = { 21 | name: 'notes', 22 | cooldown: 15, 23 | description: 'Untuk menyimpan note atau catatan di group\nPenggunaan: !notes ', 24 | async execute (client: any, chat: any, pesan: any, args: any) { 25 | if (!client.isGroup) return client.reply(pesan.error.group) 26 | if (!client.isGmium) return client.reply(pesan.hanya.premium) 27 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 28 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 29 | const arg = client.body.slice(7) 30 | if (args == 0) { 31 | await databaseView('SELECT * FROM notes') 32 | .then((hasil: any) => { 33 | let text = 'Daftar *notes* di group ini\n\n' 34 | if (hasil.length > 0) { 35 | for (const list of hasil) { 36 | if (list.gid == client.groupId) { 37 | text += `- *${list.key}*` 38 | } 39 | } 40 | client.reply(text) 41 | } else { 42 | text += '_Belum ada notes_' 43 | client.reply(text) 44 | } 45 | }) 46 | } else if (arg.split('|')[0].trim() == 'save') { 47 | const key = arg.split('|')[1] 48 | const res = arg.split('|')[2] 49 | databaseInput(`INSERT INTO notes(gid, key, res) VALUES ('${client.groupId}', '#${key}', '${res}')`) 50 | .then(() => client.reply('Berhasil menambahkan notes')) 51 | } else if (arg.split('|')[0].trim() == 'remove') { 52 | const key = arg.split('|')[1].trim() 53 | databaseInput(`DELETE FROM notes WHERE key = ${key} AND gid = ${client.groupId}`) 54 | .then(() => client.reply(`Berhasil menghapus notes #${key}`)) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/command/nulis.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import { getBuffer } from '../utils/functions' 20 | import { fetchJson } from '../utils/fetcher' 21 | 22 | module.exports = { 23 | name: 'nulis', 24 | aliases: ['n'], 25 | cooldown: 50, 26 | description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis _tulisan_', 27 | execute (client: any, chat: any, pesan: any, args: any) { 28 | const value = args.slice().join(' ') 29 | fetchJson(`https://mhankbarbar.tech/nulis?text=${value}&apiKey=${client.apiKey}`, { method: 'get' }) 30 | .then(async (hasil: any) => { 31 | client.reply(pesan.tunggu) 32 | const buffer = await getBuffer(hasil.result, { method: 'get' }) 33 | client.sendMessage(client.from, buffer, MessageType.image, { quoted: chat, caption: pesan.berhasil }) 34 | }).catch((err: string) => { 35 | console.log(err) 36 | client.log(err) 37 | }) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/command/nulis2.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import { getBuffer } from '../utils/functions' 20 | 21 | module.exports = { 22 | name: 'nulis2', 23 | aliases: ['n2'], 24 | cooldown: 50, 25 | description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis2 _tulisan_', 26 | execute (client: any, chat: any, pesan: any, args: any) { 27 | const value = args.slice().join(' ') 28 | getBuffer(`https://api.zeks.xyz/api/nulis?text=${value}&apikey=administrator`, { method: 'get' }) 29 | .then((hasil: any) => { 30 | client.reply(pesan.tunggu) 31 | client.sendMessage(client.from, hasil, MessageType.image, { quoted: chat, caption: pesan.berhasil }) 32 | }).catch((err: string) => { 33 | console.log(err) 34 | client.log(err) 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/command/nulis3.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import { getBuffer } from '../utils/functions' 20 | import { fetchJson } from '../utils/fetcher' 21 | 22 | module.exports = { 23 | name: 'nulis3', 24 | aliases: ['n3'], 25 | cooldown: 50, 26 | description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis3 _tulisan_', 27 | execute (client: any, chat: any, pesan: any, args: any) { 28 | const value = args.slice().join(' ') 29 | fetchJson(`https://tools.zone-xsec.com/api/nulis.php?q=${value}`, { method: 'get' }) 30 | .then(async (hasil: any) => { 31 | client.reply(pesan.tunggu) 32 | const image = await getBuffer(hasil.image, { method: 'get' }) 33 | client.sendMessage(client.from, image, MessageType.image, { quoted: chat, caption: pesan.berhasil }) 34 | }).catch((err: string) => { 35 | console.log(err) 36 | client.log(err) 37 | }) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/command/paste.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { fetchJson } from '../utils/fetcher' 19 | 20 | module.exports = { 21 | name: 'paste', 22 | cooldown: 20, 23 | description: 'Untuk memaste text yang direply ke Dogbin\nPenggunaan: _quoted pesan_ !paste', 24 | execute (client: any, chat: any, pesan: any, args: any) { 25 | client.reply(pesan.tunggu) 26 | const DOGBIN = 'https://del.dog/' 27 | const text = client.type === 'extendedTextMessage' ? chat.message.extendedTextMessage.contextInfo.quotedMessage.conversation : client.body.slice(7) 28 | const options = { 29 | method: 'POST', 30 | body: `${text}` 31 | } 32 | fetchJson(DOGBIN + 'documents', options) 33 | .then((hasil: any) => { 34 | if (hasil.key == undefined) return client.reply('Paste gagal!, mungkin karena text anda mengandung custom font/emotikon') 35 | client.reply(`Paste berhasil\nDogbin URL: ${DOGBIN + hasil.key}`) 36 | }) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/command/ping.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { MessageType } from '@adiwajshing/baileys' 19 | import moment from 'moment-timezone' 20 | import { processTime } from '../utils/functions' 21 | 22 | module.exports = { 23 | name: 'ping', 24 | cooldown: 10, 25 | description: 'Menampilkan rata-rata bot merespon', 26 | execute (client: any) { 27 | client.sendMessage(client.from, `Pong!!\n${processTime(client.pingStart, moment())} _detik_`, MessageType.text).catch(console.error) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/command/pmium.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { databaseView, databaseInput } from '../utils/db' 19 | 20 | module.exports = { 21 | name: 'pmium', 22 | description: 'Untuk mengelola member premium user _only owner_', 23 | async execute (client: any, chat: any, pesan: any, args: any) { 24 | if (!client.isOwner && !client.isSudo) return client.reply(pesan.hanya.owner) 25 | const uid = args[1] 26 | if (args[0] === 'add') { 27 | databaseInput(`INSERT INTO pmium(uid) VALUES('${uid}')`) 28 | .then(() => { 29 | client.reply('Berhasil menambahkan') 30 | }).catch((err: string) => { 31 | client.reply('Gagal Menambahkan') 32 | console.log(err) 33 | }) 34 | } else if (args[0] === 'del') { 35 | const uid = args[1] 36 | databaseInput(`DELETE FROM pmium WHERE uid = '${uid}'`) 37 | .then(() => { 38 | client.reply('Berhasil menghapus') 39 | }).catch((err: string) => { 40 | client.reply('Gagal menghapus') 41 | console.log(err) 42 | }) 43 | } else if (args.length === 0) { 44 | await databaseView('SELECT * FROM pmium') 45 | .then((result: any) => { 46 | let text = '📝 Daftar *Premium* di bot ini\n' 47 | if (result.length > 0) { 48 | for (let i = 0; i < result.length; i++) { 49 | const uid = result[i].uid 50 | const waktu = result[i].waktu 51 | text += `${i}. uid: ${uid}\n` 52 | text += ` └Mulai: ${waktu}\n` 53 | } 54 | client.reply(text) 55 | } else { 56 | text += '- Belum ada member' 57 | client.reply(text) 58 | } 59 | }).catch((err: string) => { 60 | client.reply('Error mengambil database') 61 | console.log(err) 62 | }) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/command/promote.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | module.exports = { 19 | name: 'promote', 20 | aliases: ['pm'], 21 | cooldown: 10, 22 | description: 'Untuk manjadikan admin anggota di group\nPenggunaan: !promote _quoted/tag_', 23 | execute (client: any, chat: any, pesan: any) { 24 | if (!client.isGroup) return client.reply(pesan.error.group) 25 | if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) 26 | if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) 27 | if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag target yang ingin di promote!') 28 | const mentions = client.quotedId || client.mentioned 29 | let mentioned 30 | if (!Array.isArray(mentions)) { 31 | mentioned = [] 32 | mentioned.push(mentions) 33 | } else { 34 | mentioned = mentions 35 | } 36 | if (mentioned.includes(client.botNumber)) return client.reply('UDAH BOCIL KEK KONTOL IDUP PULA') 37 | if (mentioned.length > 1) { 38 | let teks = 'Perintah di terima, promote :\n' 39 | for (const _ of mentioned) { 40 | teks += `@${_.split('@')[0]}\n` 41 | } 42 | client.mentions(teks, mentioned, true) 43 | client.groupMakeAdmin(client.from, mentioned) 44 | } else { 45 | client.mentions(`Perintah di terima, menjadikan admin : @${mentioned[0].split('@')[0]} di group`, mentioned, true) 46 | client.groupMakeAdmin(client.from, mentioned) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/command/report.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | module.exports = { 19 | name: 'report', 20 | cooldown: 10, 21 | description: 'Untuk mereport user\nPenggunaan: _reply_ !report ', 22 | async execute (client: any, chat: any, pesan: any, args: any) { 23 | if (!client.isGroup) return client.reply(pesan.error.group) 24 | const memberList = await client.groupAdmins 25 | memberList.push(client.sender) 26 | if (args > 0) { 27 | const options = { 28 | text: `Report @${client.sender.split('@')[0]} terkirim ke admin\nAlasan: ${client.body.slice(8)}`, 29 | contextInfo: { mentionedJid: memberList }, 30 | quoted: chat 31 | } 32 | client.sendMess(client.from, options) 33 | } else { 34 | const options = { 35 | text: `Report @${client.sender.split('@')[0]} terkirim ke admin\nAlasan: tidak ada alasan`, 36 | contextInfo: { mentionedJid: memberList }, 37 | quoted: chat 38 | } 39 | client.sendMess(client.from, options) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/command/siaran.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* eslint-disable no-mixed-operators */ 19 | import { MessageType } from '@adiwajshing/baileys' 20 | 21 | module.exports = { 22 | name: 'siaran', 23 | description: 'Untuk mengelola member premium group _only owner_', 24 | async execute (client: any, chat: any, pesan: any, args: any) { 25 | if (!client.isOwner && !client.isSudo) return client.reply(pesan.hanya.owner) 26 | if (args.length < 1) return client.reply('Ra onok tulisan') 27 | const chatAll = await client.chats.all() 28 | if (client.isMedia && !chat.message.videoMessage || client.isQuotedImage) { 29 | const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat 30 | const buff = await client.downloadMediaMessage(encmedia) 31 | for (const _ of chatAll) { 32 | client.sendMessage(_.jid, buff, MessageType.image, { caption: `❮ *KryPtoN Bot Broadcast* ❯\n\n${client.body.slice(7)}` }) 33 | } 34 | client.reply('Berhasil mengirim siaran') 35 | } else { 36 | for (const _ of chatAll) { 37 | client.sendMess(_.jid, `❮ *KryPtoN Bot Broadcast* ❯\n\n${client.body.slice(8)}`) 38 | } 39 | client.reply('*Berhasil mengirim siaran*') 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/command/slap.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | module.exports = { 19 | name: 'slap', 20 | cooldown: 10, 21 | description: 'Untuk menampol orang\nPenggunaan !slap _quoted/tag_', 22 | execute (client: any, chat: any, pesan: any) { 23 | if (!client.isGroup) return client.reply(pesan.error.group) 24 | if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag target yang ingin di tonjok!') 25 | const mentions = client.quotedId || client.mentioned 26 | let mentioned 27 | if (!Array.isArray(mentions)) { 28 | mentioned = [] 29 | mentioned.push(mentions) 30 | } else { 31 | mentioned = mentions 32 | } 33 | const dari = client.sender 34 | const target = mentioned[0] 35 | mentioned.push(dari) 36 | const data = [ 37 | `@${dari.split('@')[0]} melempar *pisang busuk* ke @${target.split('@')[0]}`, 38 | `@${dari.split('@')[0]} bersiap-siap untuk melempar *sekop* ke @${target.split('@')[0]}`, 39 | `@${dari.split('@')[0]} manapar dengan keras @${target.split('@')[0]} dengan *50jt TON truk*`, 40 | `@${dari.split('@')[0]} mulai *memukul* @${target.split('@')[0]} dengan sendok`, 41 | `@${dari.split('@')[0]} menjatuhkan *meteor* ke @${target.split('@')[0]}`, 42 | `@${dari.split('@')[0]} bersiap-siap *me-rasengan* @${target.split('@')[0]}`, 43 | `@${dari.split('@')[0]} menulis nama @${target.split('@')[0]} di *death note*` 44 | ] 45 | const dataslap = data[Math.floor(Math.random() * data.length)] 46 | client.mentions(`${dataslap}`, mentioned, true) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/command/sticker.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* eslint-disable no-mixed-operators */ 19 | import { MessageType } from '@adiwajshing/baileys' 20 | import { exec } from 'child_process' 21 | import { getRandom } from '../utils/functions' 22 | import ffmpeg from 'fluent-ffmpeg' 23 | import fs from 'fs' 24 | import { removeBackgroundFromImageFile } from 'remove.bg' 25 | 26 | module.exports = { 27 | name: 'sticker', 28 | aliases: ['s', 'st'], 29 | cooldown: 600, 30 | description: 'Untuk menjadikan video atau gambar menjadi sticker\nPenggunaan: quoted gambar/vidio !sticker rbg: remove background, nobg: no background on sticker, default sticker dengan background', 31 | async execute (client: any, chat: any, pesan: any, args: any) { 32 | if ((client.isMedia && !chat.message.videoMessage || client.isQuotedImage) && args[0] == 'nobg') { 33 | if ((!client.isGroup && !client.isPmium) || (client.isGroup && !client.isGmium)) return client.reply(pesan.hanya.premium) 34 | const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat 35 | const media = await client.downloadAndSaveMediaMessage(encmedia) 36 | const ranw = getRandom('.webp') 37 | client.reply(pesan.tunggu) 38 | await ffmpeg(`./${media}`) 39 | .input(media) 40 | .on('start', function (cmd: string) { 41 | console.log(`[INFO] Started : ${cmd}`) 42 | }) 43 | .on('error', function (err: string) { 44 | console.log(`[INFO] Error : ${err}`) 45 | fs.unlinkSync(media) 46 | client.reply('Error saat membuat sticker') 47 | client.log(err) 48 | }) 49 | .on('end', function () { 50 | console.log('[INFO] Berhasil membuat sticker') 51 | client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) 52 | fs.unlinkSync(media) 53 | fs.unlinkSync(ranw) 54 | }) 55 | .addOutputOptions(['-vcodec', 'libwebp', '-vf', 'scale=\'min(320,iw)\':min\'(320,ih)\':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse']) 56 | .toFormat('webp') 57 | .save(ranw) 58 | } else if ((client.isMedia && chat.message.videoMessage.seconds < 11 || client.isQuotedVideo && chat.message.extendedTextMessage.contextInfo.quotedMessage.videoMessage.seconds < 11) && args.length == 0) { 59 | if ((!client.isGroup && !client.isPmium) || (client.isGroup && !client.isGmium)) return client.reply(pesan.hanya.premium) 60 | const encmedia = client.isQuotedVideo ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat 61 | const media = await client.downloadAndSaveMediaMessage(encmedia) 62 | const ranw = getRandom('.webp') 63 | client.reply(pesan.tunggu) 64 | await ffmpeg(`./${media}`) 65 | .inputFormat(media.split('.')[1]) 66 | .on('start', function (cmd: string) { 67 | console.log(`[INFO] Started : ${cmd}`) 68 | }) 69 | .on('error', function (err: string) { 70 | console.log(`[INFO] Error : ${err}`) 71 | fs.unlinkSync(media) 72 | const tipe = media.endsWith('.mp4') ? 'video' : 'gif' 73 | client.reply(`❌ Gagal, pada saat mengkonversi ${tipe} ke stiker`) 74 | client.log(err) 75 | }) 76 | .on('end', function () { 77 | console.log('[INFO] Berhasil membuat sticker') 78 | client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) 79 | fs.unlinkSync(media) 80 | fs.unlinkSync(ranw) 81 | }) 82 | .addOutputOptions(['-vcodec', 'libwebp', '-vf', 'scale=\'min(320,iw)\':min\'(320,ih)\':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse']) 83 | .toFormat('webp') 84 | .save(ranw) 85 | } else if ((client.isMedia || client.isQuotedImage) && args[0] == 'rbg') { 86 | if ((!client.isGroup && !client.isPmium) || (client.isGroup && !client.isGmium)) return client.reply(pesan.hanya.premium) 87 | const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat 88 | const media = await client.downloadAndSaveMediaMessage(encmedia) 89 | const ranw = getRandom('.webp') 90 | const ranp = getRandom('.png') 91 | client.reply(pesan.tunggu) 92 | const keyrmbg = process.env.KEY_REMOVEBG 93 | await removeBackgroundFromImageFile({ path: media, apiKey: `${keyrmbg}`, size: 'auto', type: 'auto', outputFile: ranp }).then((res: any) => { 94 | fs.unlinkSync(media) 95 | exec(`ffmpeg -i ${ranp} -vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 512:512 ${ranw}`, (err: any) => { 96 | fs.unlinkSync(ranp) 97 | if (err) return client.reply('Error saat membuat sticker') 98 | client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) 99 | }) 100 | }).catch((err: Array) => { 101 | client.log(err) 102 | return client.reply('Gagal, Terjadi kesalahan, silahkan coba beberapa saat lagi.') 103 | }) 104 | } else if ((client.isMedia || client.isQuotedImage) && args.length == 0) { 105 | const encmedia = client.isQuotedImage ? JSON.parse(JSON.stringify(chat).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : chat 106 | const media = await client.downloadAndSaveMediaMessage(encmedia) 107 | const ranw = getRandom('.webp') 108 | await ffmpeg(`./${media}`) 109 | .on('start', function (cmd: any) { 110 | console.log('[INFO] Started :', cmd) 111 | }) 112 | .on('error', function (err: any) { 113 | fs.unlinkSync(media) 114 | console.log('[INFO] Error :', err) 115 | client.reply('Error saat membuat sticker') 116 | client.log(err) 117 | }) 118 | .on('end', function () { 119 | console.log('[INFO] Berhasil membuat sticker') 120 | client.sendMessage(client.from, fs.readFileSync(ranw), MessageType.sticker, { quoted: chat }) 121 | fs.unlinkSync(media) 122 | fs.unlinkSync(ranw) 123 | }) 124 | .addOutputOptions(['-vcodec', 'libwebp', '-vf', 'scale=\'min(320,iw)\':min\'(320,ih)\':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=off [p]; [b][p] paletteuse']) 125 | .toFormat('webp') 126 | .save(ranw) 127 | } else { 128 | client.reply('Kirim gambar dengan caption !sticker atau tag gambar yang sudah dikirim') 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/command/update.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // using spawn in the child process module 19 | import { spawn } from 'child_process' 20 | import { term, restart } from '../utils/functions' 21 | import { MessageType } from '@adiwajshing/baileys' 22 | 23 | module.exports = { 24 | name: 'update', 25 | description: 'OTA UPDATE Untuk mengupdate bot _only owner_', 26 | async execute (client: any, chat: any, pesan: any, args: any) { 27 | const id = client.from 28 | const quoted = chat 29 | const remote = 'https://' + process.env.GIT_PW + '@github.com/Kry9toN/KryPtoN-WhatsApp-Bot' // Change your remote link 30 | const herokuRemote = 'https://api:' + process.env.HEROKU_API + '@git.heroku.com/krypton-wa.git' // Change your link git heroku 31 | const genLog = () => new Promise((resolve, reject) => { 32 | // start get log process 33 | const git = spawn('git', ['log', '--oneline', '--no-decorate', 'HEAD..upstream/master']) 34 | // buffer for data 35 | let buf = Buffer.alloc(0) 36 | // concat 37 | git.stdout.on('data', (data: any) => { 38 | buf = Buffer.concat([buf, data]) 39 | }) 40 | // if process error 41 | git.stderr.on('data', (data: any) => { 42 | reject(data.toString()) 43 | }) 44 | // when process is done 45 | git.on('close', () => { 46 | // convert to string and split based on end of line 47 | const subjects = buf.toString().split('\n') 48 | // pop the last empty string element 49 | subjects.pop() 50 | // log all subject names 51 | let text = 'Changelog KryPtoN bot:\n' 52 | subjects.forEach((sub) => { 53 | text += `*${sub}*\n` 54 | }) 55 | resolve(text) 56 | }) 57 | }) 58 | if (args.length == 0) { 59 | client.sendMessage(id, 'Checking OTA update....', MessageType.text, { quoted: quoted }) 60 | term(`git remote add upstream ${remote}`) 61 | .then(() => { 62 | term('git fetch upstream').then(() => { 63 | genLog().then((data: any) => { 64 | if (data.length < 30) { 65 | client.sendMessage(id, 'Bot dalam kondisi terbaru', MessageType.text, { quoted: quoted }) 66 | } else { 67 | client.sendMessage(id, `OTA UPDATE\n\n${data}\nKetik *!update now/deploy* untuk mengupdatenya`, MessageType.text, { quoted: quoted }) 68 | } 69 | }).catch((err) => console.error(err)) 70 | }).catch((err: string) => console.error(err)) 71 | }).catch((err: string) => console.error(err)) 72 | } else if (args.length > 0 && args[0] == 'now') { 73 | if (!client.isOwner && !client.isSudo) return client.sendMessage(id, pesan.hanya.owner, MessageType.text, { quoted: quoted }) 74 | client.sendMessage(id, 'Tunggu... bot sedang updating', MessageType.text, { quoted: quoted }) 75 | term('git reset --hard FETCH_HEAD').then(() => { 76 | client.sendMessage(id, 'OTA Update berhasil\n Restarting bot....', MessageType.text, { quoted: quoted }) 77 | restart() 78 | }).catch((err: string) => { 79 | console.log(err) 80 | client.log(err) 81 | client.sendMessage(id, 'OTA Update gagal/error', MessageType.text, { quoted: quoted }) 82 | }) 83 | } else if (args.length > 0 && args[0] == 'deploy') { 84 | if (!client.isOwner && !client.isSudo) return client.sendMessage(id, pesan.hanya.owner, MessageType.text, { quoted: quoted }) 85 | client.sendMessage(id, 'Tunggu... bot sedang updating', MessageType.text, { quoted: quoted }) 86 | term('git reset --hard FETCH_HEAD').then(() => { 87 | term(`git remote add heroku ${herokuRemote}`).then(() => { 88 | term('git push heroku HEAD:refs/heads/master -f').then(() => { 89 | client.sendMessage(id, 'OTA Update berhasil\nRestarting bot....', MessageType.text, { quoted: quoted }) 90 | }).catch((err: string) => { 91 | console.log(err) 92 | client.log(err) 93 | client.sendMessage(id, 'OTA Update gagal/error saat menambah remote', MessageType.text, { quoted: quoted }) 94 | }) 95 | }).catch((err: string) => { 96 | console.log(err) 97 | client.log(err) 98 | client.sendMessage(id, 'OTA Update gagal/error saat deploying', MessageType.text, { quoted: quoted }) 99 | }) 100 | }).catch((err: string) => { 101 | console.log(err) 102 | client.log(err) 103 | client.sendMessage(id, 'OTA Update gagal/error', MessageType.text, { quoted: quoted }) 104 | }) 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/include/db.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { databaseInput } from '../utils/db' 19 | 20 | /*** 21 | * Initial Database 22 | **/ 23 | // Black List 24 | databaseInput('CREATE TABLE IF NOT EXISTS blacklist( id VARCHAR(30) PRIMARY KEY NOT NULL , reason CHAR(225) DEFAULT \'No Reason\')') 25 | .catch((err: string) => console.log(err)) 26 | // Filters 27 | databaseInput('CREATE TABLE IF NOT EXISTS filters( gid VARCHAR(50) NOT NULL , key VARCHAR(225) NOT NULL, res VARCHAR(225) NOT NULL )') 28 | .catch((err: string) => console.log(err)) 29 | // Notes 30 | databaseInput('CREATE TABLE IF NOT EXISTS notes( gid VARCHAR(50) NOT NULL , key VARCHAR(225) NOT NULL, res VARCHAR(225) NOT NULL )') 31 | .catch((err: string) => console.log(err)) 32 | // Premium 33 | databaseInput('CREATE TABLE IF NOT EXISTS gmium( gid VARCHAR(50) PRIMARY KEY NOT NULL, lifetime VARCHAR(10) NOT NULL, signature VARCHAR(30) NOT NULL, waktu TIMESTAMP NOT NULL DEFAULT now() )') 34 | .catch((err: string) => console.log(err)) 35 | databaseInput('CREATE TABLE IF NOT EXISTS pmium( uid VARCHAR(50) PRIMARY KEY NOT NULL, waktu TIMESTAMP NOT NULL DEFAULT now() )') 36 | .catch((err: string) => console.log(err)) 37 | // Blacklist text 38 | databaseInput('CREATE TABLE IF NOT EXISTS bllist( gid VARCHAR(50) NOT NULL , text VARCHAR(225) NOT NULL)') 39 | .catch((err: string) => console.log(err)) 40 | // Blacklist user 41 | databaseInput('CREATE TABLE IF NOT EXISTS warn( gid VARCHAR(50) NOT NULL, uid VARCHAR(30) NOT NULL , warn VARCHAR(100) NOT NULL)') 42 | .catch((err: string) => console.log(err)) 43 | // Sudo 44 | databaseInput('CREATE TABLE IF NOT EXISTS sudo( id VARCHAR(30) PRIMARY KEY NOT NULL )') 45 | .catch((err: string) => console.log(err)) 46 | // Sudo 47 | databaseInput('CREATE TABLE IF NOT EXISTS afks( uid VARCHAR(30) PRIMARY KEY NOT NULL, afk VARCHAR(10) NOT NULL, reason CHAR(225) NOT NULL, timestart VARCHAR(100) NOT NULL )') 48 | .catch((err: string) => console.log(err)) 49 | // Locales 50 | databaseInput('CREATE TABLE IF NOT EXISTS locales( id VARCHAR(30) PRIMARY KEY NOT NULL, locale VARCHAR(10) NOT NULL)') 51 | .catch((err: string) => console.log(err)) 52 | -------------------------------------------------------------------------------- /src/include/locale.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | export {} 19 | import i18n from 'i18n' 20 | import path from 'path' 21 | 22 | i18n.configure({ 23 | locales: ['en', 'id'], 24 | directory: path.join(__dirname, '../../locales'), 25 | defaultLocale: 'en', 26 | objectNotation: true, 27 | register: global, 28 | 29 | logWarnFn: function (msg: string) { 30 | console.log('[INFO]', msg) 31 | }, 32 | 33 | logErrorFn: function (msg: string) { 34 | console.log('[INFO]', msg) 35 | }, 36 | 37 | missingKeyFn: function (locale: string, value: string) { 38 | return value 39 | }, 40 | 41 | mustacheConfig: { 42 | tags: ['{{', '}}'], 43 | disable: false 44 | } 45 | }) 46 | -------------------------------------------------------------------------------- /src/krypton.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-var-requires 19 | const { WAConnection } = require('@adiwajshing/baileys') 20 | import { MessageType } from '@adiwajshing/baileys' 21 | import { Collection } from 'discord.js' 22 | import { readdirSync } from 'fs' 23 | import { join } from 'path' 24 | import { start, success, getGroupAdmins } from './utils/functions' 25 | import { color } from './utils/color' 26 | import fs from 'fs' 27 | import moment from 'moment-timezone' 28 | import { welcome, goodbye } from './utils/greeting' 29 | import { databaseView } from './utils/db' 30 | import { web, loging, qrCode } from './utils/web' 31 | import i18n from 'i18n' 32 | import getLocale from './utils/locale' 33 | 34 | // eslint-disable-next-line @typescript-eslint/no-var-requires 35 | require('dotenv').config() 36 | 37 | async function krypton () { 38 | const client = new WAConnection() 39 | client.cmd = new Collection() 40 | client.runtimeDb = new Collection() 41 | client.botNumber = process.env.BOT_NUMBER 42 | const cooldowns = new Collection() 43 | 44 | // Initial locale 45 | require('./include/locale') 46 | 47 | // Web API client 48 | web(client) 49 | 50 | // Initial db 51 | require('./include/db') 52 | 53 | client.logger.level = 'warn' 54 | 55 | client.browserDescription = ['KryPtoN', 'Chrome', '87'] 56 | 57 | await client.on('qr', (qr: string) => { 58 | console.log(color('[', 'white'), color('!', 'red'), color(']', 'white'), color(' Scan the QR code above', 'blue')) 59 | qr = encodeURIComponent(qr) 60 | qrCode(qr) 61 | }) 62 | 63 | // Connect to sessions if already exist 64 | if (fs.existsSync('./sessions/krypton-sessions.json')) { 65 | await client.loadAuthInfo('./sessions/krypton-sessions.json') 66 | await client.on('connecting', () => { 67 | start('1', '[INFO] Menyambungkan ke sessions yang sudah ada...') 68 | }) 69 | } 70 | 71 | // Server connecting 72 | if (!fs.existsSync('./sessions/krypton-sessions.json')) { 73 | await client.on('connecting', () => { 74 | start('1', '[INFO] Menunggu scan code QR untuk menyambungkan...') 75 | }) 76 | } 77 | 78 | // Server connected 79 | await client.on('open', () => { 80 | success('1', '[INFO] Terhubung') 81 | console.log('🤖', color('KryPtoN Bot Sudah siap!!', 'green')) 82 | }) 83 | 84 | // Create file for sessions 85 | await client.connect({ timeoutMs: 30 * 1000 }) 86 | fs.writeFileSync('./sessions/krypton-sessions.json', JSON.stringify(client.base64EncodedAuthInfo(), null, '\t')) 87 | 88 | // Notes event 89 | client.on('message', async ({ client }: any) => { 90 | const keyWord = client.body.toLowerCase() 91 | // Notes 92 | await databaseView('SELECT * FROM notes') 93 | .then((hasil: any) => { 94 | const filterBaseString = JSON.stringify(hasil) 95 | if (filterBaseString.includes(client.groupId)) { 96 | for (let i = 0; i < hasil.length; i++) { 97 | if (keyWord.includes(hasil[i].key && hasil[i].gid == client.groupId)) { 98 | const resMessage = hasil[i].res 99 | client.reply(resMessage) 100 | } 101 | } 102 | } 103 | }).catch((err: string) => console.log(err)) 104 | }) 105 | 106 | await client.on('group-participants-update', async (greeting: any) => { 107 | try { 108 | const num = greeting.participants[0] 109 | const mdata = await client.groupMetadata(greeting.jid) 110 | const name = client.contacts[num] != undefined ? client.contacts[num].vname || client.contacts[num].notify : undefined 111 | const ppimg = await client.getProfilePicture(`${greeting.participants[0].split('@')[0]}@c.us`) 112 | if (greeting.action == 'add') { 113 | console.log(color('~', 'yellow'), color('EXEC', 'red'), client.time, 'client', color(greeting.participants[0].split('@')[0], 'yellow'), 'Masuk ke group', color(mdata.subject, 'blue')) 114 | await welcome(name, mdata.subject, ppimg).then(async (hasil: any) => { 115 | await client.sendMessage(mdata.id, hasil, MessageType.image) 116 | }) 117 | } else if (greeting.action == 'remove') { 118 | console.log(color('~', 'yellow'), color('EXEC', 'red'), client.time, 'client', color(greeting.participants[0].split('@')[0], 'yellow'), 'Keluar dari group', color(mdata.subject, 'blue')) 119 | await goodbye(name, mdata.subject, ppimg).then(async (hasil: any) => { 120 | await client.sendMessage(mdata.id, hasil, MessageType.image) 121 | }) 122 | } 123 | } catch (e) { 124 | console.log('[INFO] : %s', color(e, 'red')) 125 | } 126 | }) 127 | 128 | await client.on('chat-update', async (chat: any) => { 129 | if (!chat.hasNewMessage) return 130 | client.pingStart = chat.t 131 | chat = chat.messages.all()[0] 132 | if (!chat.message) return 133 | if (chat.key.remoteJid == 'status@broadcast') return 134 | if (chat.key.fromMe) return 135 | client.time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss') 136 | client.apiKey = process.env.API_KEY 137 | const prefix = '!' 138 | 139 | // Variable 140 | client.type = Object.keys(chat.message)[0] 141 | client.body = client.type === 'conversation' ? chat.message.conversation : (client.type == 'imageMessage') ? chat.message.imageMessage.caption : (client.type == 'videoMessage') ? chat.message.videoMessage.caption : (client.type == 'extendedTextMessage') ? chat.message.extendedTextMessage.text : '' 142 | const args = client.body.trim().split(/ +/).slice(1) 143 | client.isCmd = client.body.startsWith(prefix) 144 | client.commandName = client.body.slice(1).trim().split(/ +/).shift().toLowerCase() 145 | const content = JSON.stringify(chat.message) 146 | const botNumber = client.user.jid 147 | const ownerNumber = process.env.OWNER_PHONE // Isi di .env 148 | const logGroup = process.env.LOGGING // Isi di .env 149 | client.from = chat.key.remoteJid 150 | exports.ID = client.from 151 | client.isGroup = client.from.endsWith('@g.us') 152 | client.sender = client.isGroup ? chat.participant : chat.key.remoteJid 153 | const groupMetadata = client.isGroup ? await client.groupMetadata(client.from) : '' 154 | client.groupName = client.isGroup ? groupMetadata.subject : '' 155 | client.groupMembers = client.isGroup ? groupMetadata.participants : '' 156 | client.groupAdmins = client.isGroup ? getGroupAdmins(client.groupMembers) : '' 157 | client.groupId = client.isGroup ? groupMetadata.id : '' 158 | client.isBotGroupAdmins = client.groupAdmins.includes(botNumber) || false 159 | client.isGroupAdmins = client.groupAdmins.includes(client.sender) || false 160 | client.isOwner = client.sender.includes(ownerNumber) 161 | client.isUrl = (url: string) => { 162 | // eslint-disable-next-line prefer-regex-literals 163 | return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/, 'gi')) 164 | } 165 | client.reply = (teks: string) => { 166 | client.sendMessage(client.from, teks, MessageType.text, { quoted: chat }) 167 | } 168 | client.sendMess = (id: number, text: string) => { 169 | client.sendMessage(id, text, MessageType.text) 170 | } 171 | client.mentions = (teks: string, id: number, bolean: boolean) => { 172 | (bolean == null || bolean == undefined || bolean == false) ? client.sendMessage(client.from, teks.trim(), MessageType.extendedText, { contextInfo: { mentionedJid: id } }) : client.sendMessage(client.from, teks.trim(), MessageType.extendedText, { quoted: chat, contextInfo: { mentionedJid: id } }) 173 | } 174 | client.log = (error: string) => { 175 | client.sendMessage(logGroup, `[LOGGING] command: *${client.commandName}* ${error}`, MessageType.text) 176 | } 177 | 178 | client.isMedia = (client.type === 'imageMessage' || client.type === 'videoMessage') 179 | client.isQuotedImage = client.type === 'extendedTextMessage' && content.includes('imageMessage') 180 | client.isQuotedVideo = client.type === 'extendedTextMessage' && content.includes('videoMessage') 181 | client.isQuotedSticker = client.type === 'extendedTextMessage' && content.includes('stickerMessage') 182 | client.quotedId = client.type === 'extendedTextMessage' ? chat.message.extendedTextMessage.contextInfo.participant : '' 183 | client.mentioned = client.type === 'extendedTextMessage' ? chat.message.extendedTextMessage.contextInfo.mentionedJid : '' 184 | 185 | // Premuim 186 | const viewPm = await databaseView('SELECT * FROM pmium') 187 | const pmWhiteList = JSON.stringify(viewPm) 188 | client.isPmium = pmWhiteList.includes(client.sender) 189 | 190 | const viewGc = await databaseView('SELECT * FROM gmium') 191 | const gcWhiteList = JSON.stringify(viewGc) 192 | client.isGmium = gcWhiteList.includes(client.groupId) 193 | 194 | const sudo = await databaseView('SELECT * FROM sudo') 195 | const sList = JSON.stringify(sudo) 196 | client.isSudo = sList.includes(client.sender) 197 | 198 | // Web api proses 199 | loging(client) 200 | 201 | // Logging Message 202 | if (!client.isGroup && client.isCmd) console.log(color('~', 'yellow'), color('EXEC', 'red'), client.time, color(client.commandName, 'yellow'), 'from', color(client.sender.split('@')[0], 'yellow'), 'args :', color(args.length, 'blue')) 203 | if (!client.isGroup && !client.isCmd) console.log(color('~', 'yellow'), color('RECV', 'green'), client.time, color('Message', 'yellow'), 'from', color(client.sender.split('@')[0], 'yellow'), 'args :', color(args.length, 'blue')) 204 | if (client.isCmd && client.isGroup) console.log(color('~', 'yellow'), color('EXEC', 'red'), client.time, color(client.commandName, 'yellow'), 'from', color(client.sender.split('@')[0], 'yellow'), 'in', color(client.groupName, 'yellow'), 'args :', color(args.length, 'blue')) 205 | if (!client.isCmd && client.isGroup) console.log(color('~', 'yellow'), color('RECV', 'green'), client.time, color('Message', 'yellow'), 'from', color(client.sender.split('@')[0], 'yellow'), 'in', color(client.groupName, 'yellow'), 'args :', color(args.length, 'blue')) 206 | 207 | if (client.body.startsWith('#')) client.emit('message', { client }) 208 | 209 | /** 210 | * Import all commands 211 | */ 212 | const commandFiles = readdirSync(join(__dirname, 'command')).filter((file: string) => file.endsWith('.js')) 213 | for (const file of commandFiles) { 214 | // eslint-disable-next-line @typescript-eslint/no-var-requires 215 | const command = require(join(__dirname, 'command', `${file}`)) 216 | client.cmd.set(command.name, command) 217 | } 218 | 219 | if (!client.isCmd) return 220 | 221 | const command = 222 | client.cmd.get(client.commandName) || 223 | client.cmd.find((cmd: any) => cmd.aliases && cmd.aliases.includes(client.commandName)) 224 | 225 | if (!command) return 226 | 227 | await getLocale(i18n, client.from) 228 | 229 | const pesan = { 230 | tunggu: i18n.__('bot.tunggu'), 231 | gagal: i18n.__('bot.gagal'), 232 | berhasil: i18n.__('bot.berhasil'), 233 | hanya: { 234 | admin: i18n.__('bot.admin'), 235 | botAdmin: i18n.__('bot.botAdmin'), 236 | owner: i18n.__('bot.owner'), 237 | premium: i18n.__('bot.premium') 238 | }, 239 | error: { 240 | group: i18n.__('bot.group'), 241 | args: i18n.__('bot.args') 242 | } 243 | } 244 | 245 | // Time durations 246 | if ((!client.isGroup && !client.isPmium) || (client.isGroup && !client.isGmium)) { 247 | if (!cooldowns.has(command.name)) { 248 | cooldowns.set(command.name, new Collection()) 249 | } 250 | 251 | const now = Date.now() 252 | const timestamps: any = cooldowns.get(command.name) 253 | const cooldownAmount = (command.cooldown || 1) * 1000 254 | 255 | if (timestamps.has(client.from)) { 256 | const expirationTime = timestamps.get(client.from) + cooldownAmount 257 | 258 | if (now < expirationTime) { 259 | const timeLeft = (expirationTime - now) / 1000 260 | return client.sendMessage(client.from, 261 | `[Slow mode] Mohon tunggu lebih dari ${timeLeft.toFixed(1)} detik sebelum menggunakan perintah *${command.name}* kembali.\n\n Berlangganan lah agar tidak selalu menunggu seperti ini, ketik *!pricing* untuk info harga, dll`, 262 | MessageType.text 263 | ) 264 | } 265 | } 266 | 267 | timestamps.set(client.from, now) 268 | setTimeout(() => timestamps.delete(client.from), cooldownAmount) 269 | } 270 | 271 | try { 272 | command.execute(client, chat, pesan, args) 273 | } catch (e) { 274 | console.log('[INFO] : %s', color(e, 'red')) 275 | client.sendMessage(client.from, 'Telah terjadi error setelah menggunakan command ini.', MessageType.text) 276 | client.log(e) 277 | } 278 | }) 279 | } 280 | 281 | krypton().catch((err) => console.log('[INFO] : %s', color(err, 'red'))) 282 | -------------------------------------------------------------------------------- /src/utils/color.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import chalk from 'chalk' 19 | 20 | export const color = (text: string, color: string) => { 21 | return !color ? chalk.green(text) : chalk.keyword(color)(text) 22 | } 23 | 24 | export const bgcolor = (text: string, bgcolor: string) => { 25 | return !bgcolor ? chalk.green(text) : chalk.bgKeyword(bgcolor)(text) 26 | } 27 | -------------------------------------------------------------------------------- /src/utils/db.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-var-requires 19 | require('dotenv').config() 20 | process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0' 21 | import { Pool } from 'pg' 22 | const optionsAndoid = { 23 | user: process.env.DB_USER, 24 | host: process.env.DB_HOST, 25 | database: process.env.DB_NAME, 26 | password: process.env.DB_PW, 27 | port: 5432 28 | } 29 | const options = { 30 | connectionString: process.env.DATABASE_URL, 31 | connectionTimeoutMillis: 2500, 32 | idleTimeoutMillis: 2000, 33 | max: 10000, 34 | ssl: true 35 | } 36 | const pool = new Pool(process.platform == 'android' ? optionsAndoid : options) 37 | 38 | export const databaseInput = (value: string) => new Promise((resolve, reject) => { 39 | pool.query(value, (err: any, result: any) => { 40 | if (err) { 41 | console.error(err) 42 | reject(err) 43 | } 44 | resolve(result) 45 | }) 46 | }) 47 | 48 | export const databaseView = (value: string) => new Promise((resolve, reject) => { 49 | pool.query(value, (err: any, result: any) => { 50 | if (err) { 51 | console.error(err) 52 | reject(err) 53 | } 54 | resolve(result.rows) 55 | }) 56 | }) 57 | 58 | export const dbLocale = (id: any) => new Promise((resolve, reject) => { 59 | pool.query('SELECT * FROM locales', (err: any, result: any) => { 60 | if (err) { 61 | console.error(err) 62 | reject(err) 63 | } 64 | let defLocal = 'en' 65 | const rows = result.rows 66 | const isInclude = JSON.stringify(rows).includes(id) 67 | if (rows.length == 0) { 68 | resolve(defLocal) 69 | } else if (!isInclude) { 70 | resolve(defLocal) 71 | } else { 72 | for (const lang of rows) { 73 | if (lang.id == id || lang.id.includes(id)) { 74 | defLocal = lang.locale 75 | resolve(defLocal) 76 | } 77 | } 78 | } 79 | }) 80 | }) 81 | -------------------------------------------------------------------------------- /src/utils/fetcher.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import fetch from 'node-fetch' 19 | import fs from 'fs' 20 | 21 | export const getBase64 = async (url: string) => { 22 | const response = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } }) 23 | if (!response.ok) throw new Error(`unexpected response ${response.statusText}`) 24 | const buffer = await response.buffer() 25 | const videoBase64 = `data:${response.headers.get('content-type')};base64,` + buffer.toString('base64') 26 | if (buffer) { return videoBase64 } 27 | } 28 | 29 | export const fetchJson = (url: string, options: any) => new Promise((resolve, reject) => { 30 | fetch(url, options) 31 | .then((response: any) => response.json()) 32 | .then((json: any) => { 33 | // console.log(json) 34 | resolve(json) 35 | }) 36 | .catch((err: string) => { 37 | reject(err) 38 | }) 39 | }) 40 | 41 | export const fetchText = (url: string, options: any) => new Promise((resolve, reject) => { 42 | fetch(url, options) 43 | .then((response: any) => response.text()) 44 | .then((text: string) => { 45 | // console.log(text) 46 | resolve(text) 47 | }) 48 | .catch((err: string) => { 49 | reject(err) 50 | }) 51 | }) 52 | 53 | // exports.getBase64 = getBase64; 54 | -------------------------------------------------------------------------------- /src/utils/functions.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-var-requires 19 | let Spin = require('spinnies') 20 | import moment from 'moment-timezone' 21 | import axios from 'axios' 22 | import { exec } from 'child_process' 23 | 24 | const spinner = { 25 | interval: 120, 26 | frames: [ 27 | '🕐', 28 | '🕑', 29 | '🕒', 30 | '🕓', 31 | '🕔', 32 | '🕕', 33 | '🕖', 34 | '🕗', 35 | '🕘', 36 | '🕙', 37 | '🕚', 38 | '🕛' 39 | ] 40 | } 41 | 42 | let globalSpinner: string 43 | 44 | export const getGlobalSpinner = (disableSpins = false) => { 45 | if (!globalSpinner) globalSpinner = new Spin({ color: 'blue', succeedColor: 'green', spinner, disableSpins }) 46 | return globalSpinner 47 | } 48 | 49 | Spin = getGlobalSpinner(false) 50 | 51 | export const start = (id: string, text: string) => { 52 | Spin.add(id, { text: text }) 53 | } 54 | 55 | export const success = (id: string, text: string) => { 56 | Spin.succeed(id, { text: text }) 57 | } 58 | 59 | /** 60 | * Get Time duration 61 | * @param {Date} timestamp 62 | * @param {Date} now 63 | */ 64 | export const processTime = (timestamp: number, now: any) => { 65 | // timestamp => timestamp when message was received 66 | return moment.duration(now - (timestamp * 1000)).asSeconds() 67 | } 68 | 69 | export const getGroupAdmins = (participants: Array) => { 70 | const admins = [] 71 | for (const i of participants) { 72 | i.isAdmin ? admins.push(i.jid) : '' 73 | } 74 | return admins 75 | } 76 | 77 | export const getBuffer = async (url: string, options: any) => { 78 | try { 79 | options || {} 80 | const res = await axios({ 81 | method: 'get', 82 | url, 83 | headers: { 84 | DNT: 1, 85 | 'Upgrade-Insecure-Request': 1 86 | }, 87 | ...options, 88 | responseType: 'arraybuffer' 89 | }) 90 | return res.data 91 | } catch (e) { 92 | console.log(`Error : ${e}`) 93 | } 94 | } 95 | 96 | export const getRandom = (ext: string) => { 97 | return `${Math.floor(Math.random() * 10000)}${ext}` 98 | } 99 | 100 | export const term = (param: string) => new Promise((resolve, reject) => { 101 | console.log('Run terminal =>', param) 102 | exec(param, (error: any, stdout: string, stderr: string) => { 103 | if (error) { 104 | console.log(error.message) 105 | resolve(error.message) 106 | } 107 | if (stderr) { 108 | console.log(stderr) 109 | resolve(stderr) 110 | } 111 | console.log(stdout) 112 | resolve(stdout) 113 | }) 114 | }) 115 | 116 | export const restart = () => { 117 | setTimeout(function () { 118 | // Kapan NodeJs keluar 119 | process.on('exit', function () { 120 | // eslint-disable-next-line @typescript-eslint/no-var-requires 121 | require('child_process').spawn(process.argv.shift(), process.argv, { 122 | cwd: process.cwd(), 123 | detached: true, 124 | stdio: 'inherit' 125 | }) 126 | }) 127 | process.exit() 128 | }, 2000) 129 | } 130 | -------------------------------------------------------------------------------- /src/utils/greeting.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-var-requires 19 | const Canvas = require('wa-canvas') 20 | 21 | export const welcome = (pushname: string, gcname: string, picprofil: string) => new Promise((resolve, reject) => { 22 | async function welcome () { 23 | const image = await new Canvas.Welcome() 24 | .setUsername(pushname) 25 | .setGuildName(gcname) 26 | .setAvatar(picprofil) 27 | .setColor('border', '#8015EA') 28 | .setColor('username-box', '#8015EA') 29 | .setColor('message-box', '#8015EA') 30 | .setColor('title', '#8015EA') 31 | .setColor('avatar', '#8015EA') 32 | .toAttachment() 33 | 34 | const buff = image.toBuffer() 35 | return buff 36 | } 37 | welcome().then((hasil) => resolve(hasil)).catch((err) => { 38 | reject(err) 39 | }) 40 | }) 41 | 42 | export const goodbye = (pushname: string, gcname: string, picprofil: string) => new Promise((resolve, reject) => { 43 | async function goodbye () { 44 | const image = await new Canvas.Goodbye() 45 | .setUsername(pushname) 46 | .setGuildName(gcname) 47 | .setAvatar(picprofil) 48 | .setColor('border', '#8015EA') 49 | .setColor('username-box', '#8015EA') 50 | .setColor('message-box', '#8015EA') 51 | .setColor('title', '#8015EA') 52 | .setColor('avatar', '#8015EA') 53 | .toAttachment() 54 | 55 | const buff = image.toBuffer() 56 | return buff 57 | } 58 | goodbye().then((hasil) => resolve(hasil)).catch((err) => { 59 | reject(err) 60 | }) 61 | }) 62 | -------------------------------------------------------------------------------- /src/utils/locale.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import { dbLocale } from './db' 19 | 20 | export default async (i18n: any, id: string) => { 21 | await dbLocale(id).then((locale: any) => { 22 | i18n.setLocale(locale) 23 | }) 24 | } 25 | -------------------------------------------------------------------------------- /src/utils/web.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-var-requires */ 2 | /* 3 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 4 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | // REQUIRE NPM PACKAGES 20 | import { MessageType } from '@adiwajshing/baileys' 21 | import http from 'http' 22 | import express from 'express' 23 | const app = express() 24 | const httpServer = http.createServer(app) 25 | const osUtils = require('node-os-utils') 26 | import os from 'os' 27 | const io = require('socket.io')(httpServer) 28 | import { color } from './color' 29 | 30 | export const web = async (client: any) => { 31 | const apiKey = process.env.WEB_API 32 | // View Engine and static public folder 33 | app.set('view engine', 'ejs') 34 | app.use(express.static('./views')) 35 | 36 | // Root Route 37 | app.get('/', (req: any, res: any) => { 38 | res.render('index.ejs') 39 | }) 40 | 41 | app.get('/send', (req: any, res: any) => { 42 | const id = req.query.id 43 | const text = req.query.text 44 | const api = req.query.api 45 | if (api !== apiKey) return res.json({ info: 'Api Key salah', status: 502 }) 46 | client.sendMessage(id, text, MessageType.text) 47 | .then(() => { 48 | res.json({ info: 'Berhasil mengirim', status: 200 }) 49 | }).catch((err: string) => res.json({ info: err, status: 502 })) 50 | }) 51 | 52 | // CPU USAGE 53 | const cpu = osUtils.cpu 54 | 55 | // USER and OS 56 | const username = os.userInfo({ encoding: 'buffer' }).username 57 | const osInfo = os.type() 58 | 59 | // SOCKET IO 60 | io.on('connection', (socket: any) => { 61 | console.log(color(`[INFO] ${socket.id} Server socket connected`, 'green')) 62 | // USE SET INTERVAL TO CHECK RAM USAGE EVERY SECOND 63 | setInterval(async () => { 64 | // RAM USED tot - free 65 | const ramUsed = Math.round(os.totalmem()) - Math.round(os.freemem()) 66 | // RAM percentage 67 | const ram = (ramUsed * 100 / Math.round(os.totalmem())).toFixed(0) 68 | // Uptime and Chat 69 | const chat = await client.chats.all().length 70 | const uptime = Math.round(process.uptime()).toFixed(0) 71 | 72 | // CPU USAGE PERCENTAGE 73 | cpu.usage().then((cpu: number) => socket.emit('ram-usage', { ram, cpu, username, osInfo, chat, uptime, loging })) 74 | }, 1000) 75 | }) 76 | 77 | // Run the server 78 | const PORT = process.env.PORT || 4242 79 | httpServer.listen(PORT, () => { 80 | console.log(color('[INFO] Web api Server on port: ', 'green') + color(`${PORT}`, 'yellow')) 81 | }) 82 | } 83 | 84 | export const loging = (client: any) => { 85 | let loging 86 | if (!client.isGroup && client.isCmd) loging = `=> ${client.time} ${client.commandName} from ${client.sender.split('@')[0]}` 87 | if (!client.isGroup && !client.isCmd) loging = `=> ${client.time} Message from ${client.sender.split('@')[0]}` 88 | if (client.isCmd && client.isGroup) loging = `=> ${client.time} ${client.commandName} from ${client.sender.split('@')[0]} in ${client.groupName}` 89 | if (!client.isCmd && client.isGroup) loging = `=> ${client.time} Message from ${client.sender.split('@')[0]} in ${client.groupName}` 90 | io.emit('log', { loging }) 91 | } 92 | 93 | export const qrCode = (qr: string) => { 94 | io.emit('qr-regen', { qr }) 95 | } 96 | -------------------------------------------------------------------------------- /start.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | const { execSync } = require('child_process') 19 | const cfonts = require('cfonts') 20 | const chalk = require('chalk') 21 | 22 | const color = (text, color) => { 23 | return !color ? chalk.green(text) : chalk.keyword(color)(text) 24 | } 25 | 26 | const banner = cfonts.render(('KRYPTON|WHATSAPP|BOT'), { 27 | font: 'block', 28 | colors: ['red', 'blue'], 29 | align: 'center', 30 | lineHeight: 2 31 | }) 32 | 33 | start() 34 | 35 | function start () { 36 | console.info(banner.string) 37 | console.info(color('[INFO] Compiling source...', 'yellow')) 38 | execSync('npm run compile') 39 | console.info(color('[INFO] Done compiling, starting the bot...', 'green')) 40 | require('./dist/krypton.js') 41 | } 42 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "target": "ES2020", 5 | "module": "commonjs", 6 | "outDir": "dist", 7 | "esModuleInterop": true, 8 | "allowSyntheticDefaultImports": true, 9 | "skipLibCheck": true, 10 | "noEmitHelpers": true, 11 | "incremental": true, 12 | "resolveJsonModule": true, 13 | "strict": true, 14 | "importHelpers": true 15 | }, 16 | "include": ["src/*/**.ts", "src/*.ts"] 17 | } 18 | -------------------------------------------------------------------------------- /views/css/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | @import url('https://fonts.googleapis.com/css2?family=Oswald&display=swap'); 19 | * { 20 | margin: 0; 21 | padding: 0; 22 | box-sizing: border-box; 23 | } 24 | 25 | body { 26 | font-family: 'Oswald', sans-serif; 27 | color: #808080; 28 | } 29 | 30 | h1 { 31 | font-size: 4rem; 32 | padding: 10px; 33 | margin: 10px auto; 34 | } 35 | 36 | .content { 37 | display: flex; 38 | flex-direction: column; 39 | justify-content: center; 40 | align-items: center; 41 | width: 100%; 42 | height: 100%; 43 | } 44 | 45 | .log-label, 46 | .uptime, 47 | .bot, 48 | .server, 49 | .chat, 50 | .user, 51 | .os { 52 | font-size: 1.1rem; 53 | height: 30px; 54 | } 55 | 56 | label { 57 | margin: 5px auto; 58 | } 59 | .innerBar-ram, 60 | .innerBar-cpu { 61 | background: linear-gradient(to right, #3fffa2 0%, #ffdb3a 50%, #e5405e 100%); 62 | height: 20px; 63 | width: 0%; 64 | } 65 | .outerContainer-ram, 66 | .outerContainer-cpu { 67 | width: 250px; 68 | height: 20px; 69 | border-radius: 5px; 70 | overflow: hidden; 71 | background: lightgray; 72 | } 73 | 74 | footer { 75 | position: fixed; 76 | bottom: 10px; 77 | text-align: center; 78 | padding: 10px; 79 | left: 50%; 80 | transform: translate(-50%); 81 | } 82 | 83 | .home { 84 | text-decoration: none; 85 | position: sticky; 86 | top: 10px; 87 | left: 50%; 88 | transform: translate(-50%); 89 | } 90 | 91 | .home .home-svg { 92 | width: 20px; 93 | display: inline-block; 94 | } 95 | 96 | @media (max-width: 768px) { 97 | h1 { 98 | font-size: 3rem; 99 | } 100 | } 101 | 102 | .log { 103 | display: inline-block; 104 | position: relative; 105 | width: 80px; 106 | height: 80px; 107 | } 108 | .log div { 109 | position: absolute; 110 | top: 33px; 111 | width: 13px; 112 | height: 13px; 113 | border-radius: 50%; 114 | background: red; 115 | animation-timing-function: cubic-bezier(0, 1, 1, 0); 116 | } 117 | .log div:nth-child(1) { 118 | left: 8px; 119 | animation: lds-ellipsis1 0.6s infinite; 120 | } 121 | .log div:nth-child(2) { 122 | left: 8px; 123 | animation: lds-ellipsis2 0.6s infinite; 124 | } 125 | .log div:nth-child(3) { 126 | left: 32px; 127 | animation: lds-ellipsis2 0.6s infinite; 128 | } 129 | .log div:nth-child(4) { 130 | left: 56px; 131 | animation: lds-ellipsis3 0.6s infinite; 132 | } 133 | @keyframes lds-ellipsis1 { 134 | 0% { 135 | transform: scale(0); 136 | } 137 | 100% { 138 | transform: scale(1); 139 | } 140 | } 141 | @keyframes lds-ellipsis3 { 142 | 0% { 143 | transform: scale(1); 144 | } 145 | 100% { 146 | transform: scale(0); 147 | } 148 | } 149 | @keyframes lds-ellipsis2 { 150 | 0% { 151 | transform: translate(0, 0); 152 | } 153 | 100% { 154 | transform: translate(24px, 0); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /views/index.ejs: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Monitoring Bot 25 | 26 | 27 | 28 | 29 | 30 |
31 |

KryPtoN Bot Resources

32 |
Hello
33 | 34 |
OS Type
35 | 36 | 37 |
38 |
39 |
40 | 41 | 42 |
43 |
44 |
45 | 46 | 47 |
Total Chat:
48 | 49 |
Uptime:
50 | 51 |
52 |
53 |
54 | 55 |
KryPtoN 😎 ©2021
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /views/js/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the KryPtoN Bot WA distribution (https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot). 3 | * Copyright (c) 2021 Dhimas Bagus Prayoga. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, version 3. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* eslint-disable no-new */ 19 | // SOCKET IO 20 | const socket = io() 21 | // SELECT ELEMENTS 22 | const labelRam = document.querySelector('.ram-label') 23 | const labelCpu = document.querySelector('.cpu-label') 24 | const user = document.querySelector('.user') 25 | const os = document.querySelector('.os') 26 | const chatTotal = document.querySelector('.chat') 27 | const onTime = document.querySelector('.uptime') 28 | const log = document.querySelector('.log') 29 | const qrCode = document.querySelector('.qr') 30 | 31 | // ON CONNECT EVENT 32 | socket.on('connect', () => { 33 | console.log('Connected') 34 | }) 35 | // ON RAM USAGE EVENT 36 | socket.on('ram-usage', ({ ram, cpu, username, osInfo, chat, uptime }) => { 37 | // SHOW OS USER INFO 38 | user.innerHTML = `Hello ${username}` 39 | os.innerHTML = `OS type: ${osInfo === 'Windows_NT' ? 'Microsoft Windows' : osInfo}` 40 | // Set ram label 41 | labelRam.innerHTML = `RAM ${ram} % ` 42 | // Set Ram bar 43 | $('.innerBar-ram').animate({ width: `${ram}%` }, 500) 44 | // Set cpu label 45 | labelCpu.innerHTML = `CPU ${cpu} % ` 46 | // Set cpu bar 47 | $('.innerBar-cpu').animate({ width: `${cpu}%` }, 500) 48 | // Check 49 | if (cpu > 90) { 50 | notify(cpu) 51 | } 52 | chatTotal.innerHTML = `Total CHAT: ${chat}` 53 | 54 | function botUpTime (seconds) { 55 | function pad (s) { 56 | return (s < 10 ? '0' : '') + s 57 | } 58 | const hours = Math.floor(seconds / (60 * 60)) 59 | const minutes = Math.floor(seconds % (60 * 60) / 60) 60 | seconds = Math.floor(seconds % 60) 61 | 62 | // return pad(hours) + ':' + pad(minutes) + ':' + pad(seconds) 63 | onTime.innerHTML = `Uptime: ${pad(hours)}Jam ${pad(minutes)}Menit ${pad(seconds)}Detik` 64 | } 65 | botUpTime(uptime) 66 | }) 67 | 68 | socket.on('log', ({ loging }) => { 69 | log.innerHTML = `${loging}` 70 | }) 71 | 72 | socket.on('qr-regen', ({ qr }) => { 73 | qrCode.innerHTML = `` 74 | }) 75 | 76 | // NOTIFICATION FUNCTION 77 | const notify = (info) => { 78 | // If granted 79 | if (Notification.permission === 'granted') { 80 | new Notification('Title', { 81 | body: `CPU over ${info} %` 82 | }) 83 | } 84 | // If denied 85 | if (Notification.permission !== 'denied') { 86 | Notification.requestPermission() 87 | .then((permission) => { 88 | if (permission === 'granted') { 89 | new Notification('Title', { 90 | body: `CPU over ${info} %` 91 | }) 92 | }; 93 | }) 94 | }; 95 | } 96 | --------------------------------------------------------------------------------