Dhimas Bagus Prayoga 💻 |
132 | dαvιѕтα 🐛 |
133 |
",
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 |
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 |
--------------------------------------------------------------------------------