├── allfunc ├── Readme.txt ├── owner.json ├── premium.json ├── followedChannels.json ├── module.js ├── color.js ├── Data6.js ├── Data7.js ├── myfunc.js ├── remini.js ├── tictactoe.js ├── myfunc2.js ├── exif.js ├── Data2.js ├── myfunc4.js ├── Data1.js ├── storage.js ├── myfunc1.js ├── myfunction.js └── myfunc3.js ├── media ├── Readme.txt ├── image1.jpg ├── menu.mp3 ├── scar1.jpg └── thumb.png ├── database └── database.json ├── package.json ├── setting └── config.js └── README.md /allfunc/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /media/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /database/database.json: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /allfunc/owner.json: -------------------------------------------------------------------------------- 1 | ["2348088549115"] -------------------------------------------------------------------------------- /allfunc/premium.json: -------------------------------------------------------------------------------- 1 | ["2348088549115"] -------------------------------------------------------------------------------- /media/image1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BADBOI-v1/scarlet-md/HEAD/media/image1.jpg -------------------------------------------------------------------------------- /media/menu.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BADBOI-v1/scarlet-md/HEAD/media/menu.mp3 -------------------------------------------------------------------------------- /media/scar1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BADBOI-v1/scarlet-md/HEAD/media/scar1.jpg -------------------------------------------------------------------------------- /media/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BADBOI-v1/scarlet-md/HEAD/media/thumb.png -------------------------------------------------------------------------------- /allfunc/followedChannels.json: -------------------------------------------------------------------------------- 1 | ["120363290640941556@newsletter","120363290640941556@newsletter"] -------------------------------------------------------------------------------- /allfunc/module.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | modul: { 3 | 4 | googleTTS: require('google-tts-api'), 5 | FormData: require('form-data'), 6 | } 7 | } -------------------------------------------------------------------------------- /allfunc/color.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk') 2 | 3 | const color = (text, color) => { 4 | return !color ? chalk.green(text) : chalk.keyword(color)(text) 5 | } 6 | 7 | const bgcolor = (text, bgcolor) => { 8 | return !bgcolor ? chalk.green(text) : chalk.bgKeyword(bgcolor)(text) 9 | } 10 | 11 | const Lognyong = (text, color) => { 12 | return !color ? chalk.yellow('[ ! ] ') + chalk.green(text) : chalk.yellow('=> ') + chalk.keyword(color)(text) 13 | } 14 | 15 | module.exports = { 16 | color, 17 | bgcolor, 18 | Lognyong 19 | } 20 | -------------------------------------------------------------------------------- /allfunc/Data6.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch') 2 | const FormData = require('form-data') 3 | const { fromBuffer } = require('file-type') 4 | 5 | /** 6 | * Upload image to telegra.ph 7 | * Supported mimetype: 8 | * - `image/jpeg` 9 | * - `image/jpg` 10 | * - `image/png` 11 | * @param {Buffer} buffer Image Buffer 12 | */ 13 | module.exports = async buffer => { 14 | let { ext } = await fromBuffer(buffer); 15 | let bodyForm = new FormData(); 16 | bodyForm.append("fileToUpload", buffer, "file." + ext); 17 | bodyForm.append("reqtype", "fileupload"); 18 | 19 | let res = await fetch("https://catbox.moe/user/api.php", { 20 | method: "POST", 21 | body: bodyForm, 22 | }); 23 | 24 | let data = await res.text(); 25 | return data; 26 | } -------------------------------------------------------------------------------- /allfunc/Data7.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch') 2 | const FormData = require('form-data') 3 | const { fromBuffer } = require('file-type') 4 | 5 | /** 6 | * Upload epheremal file to file.io 7 | * `Expired in 1 day` 8 | * `100MB Max Filesize` 9 | * @param {Buffer} buffer File Buffer 10 | */ 11 | const fileIO = async buffer => { 12 | const { ext } = await fromBuffer(buffer) || {} 13 | let form = new FormData 14 | form.append('file', buffer, 'tmp.' + ext) 15 | let res = await fetch('https://file.io/?expires=1d', { // 1 Day Expiry Date 16 | method: 'POST', 17 | body: form 18 | }) 19 | let json = await res.json() 20 | if (!json.success) throw json 21 | return json.link 22 | } 23 | 24 | /** 25 | * Upload file to storage.restfulapi.my.id 26 | * @param {Buffer|ReadableStream|(Buffer|ReadableStream)[]} inp File Buffer/Stream or Array of them 27 | * @returns {string|null|(string|null)[]} 28 | */ 29 | const RESTfulAPI = async inp => { 30 | let form = new FormData 31 | let buffers = inp 32 | if (!Array.isArray(inp)) buffers = [inp] 33 | for (let buffer of buffers) { 34 | form.append('file', buffer) 35 | } 36 | let res = await fetch('https://storage.restfulapi.my.id/upload', { 37 | method: 'POST', 38 | body: form 39 | }) 40 | let json = await res.text() 41 | try { 42 | json = JSON.parse(json) 43 | if (!Array.isArray(inp)) return json.files[0].url 44 | return json.files.map(res => res.url) 45 | } catch (e) { 46 | throw json 47 | } 48 | } 49 | 50 | module.exports = async function (inp) { 51 | let err = false 52 | for (let upload of [RESTfulAPI, fileIO]) { 53 | try { 54 | return await upload(inp) 55 | } catch (e) { 56 | err = e 57 | } 58 | } 59 | if (err) throw err 60 | } -------------------------------------------------------------------------------- /allfunc/myfunc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create By king Badboi . 3 | * Contact Me on wa.me/2348140825959 4 | */ 5 | 6 | const fetch = require('node-fetch') 7 | const axios = require("axios"); 8 | 9 | class Function { 10 | sleep(ms) { 11 | return new Promise(resolve => setTimeout(resolve, ms)); 12 | } 13 | runtime(seconds) { 14 | seconds = Number(seconds); 15 | var d = Math.floor(seconds / (3600 * 24)); 16 | var h = Math.floor(seconds % (3600 * 24) / 3600); 17 | var m = Math.floor(seconds % 3600 / 60); 18 | var s = Math.floor(seconds % 60); 19 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 20 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 21 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 22 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 23 | return dDisplay + hDisplay + mDisplay + sDisplay; 24 | } 25 | async fetchJson(url, options = {}) { 26 | try { 27 | let data = await axios(url, { 28 | method: "get", 29 | headers: { 30 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36', 31 | origin: url, 32 | referer: url 33 | }, 34 | responseType: 'json' 35 | }) 36 | 37 | return data?.data 38 | } catch (e) { 39 | return e 40 | } 41 | } 42 | 43 | getUserName(user) { 44 | try { 45 | var last_name = user["last_name"] || "" 46 | var full_name = user.first_name + " " + last_name 47 | user["full_name"] = full_name.trim() 48 | return user 49 | } catch (e) { 50 | throw e 51 | } 52 | } 53 | isUrl(url) { 54 | 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')) 55 | } 56 | range(start, stop, step) { 57 | if (typeof stop == 'undefined') { 58 | stop = start; 59 | start = 0; 60 | } 61 | if (typeof step == 'undefined') { 62 | step = 1; 63 | } 64 | if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) { 65 | return []; 66 | } 67 | var result = []; 68 | for (var i = start; step > 0 ? i < stop : i > stop; i += step) { 69 | result.push(i); 70 | } 71 | return result; 72 | } 73 | } 74 | 75 | exports.simple = new Function() -------------------------------------------------------------------------------- /allfunc/remini.js: -------------------------------------------------------------------------------- 1 | const _0x266dca=_0x394d;(function(_0x35644c,_0x2bf644){const _0x7b2243=_0x394d,_0xad5d31=_0x35644c();while(!![]){try{const _0x3889fd=-parseInt(_0x7b2243(0xbe))/0x1*(-parseInt(_0x7b2243(0xcb))/0x2)+parseInt(_0x7b2243(0xb1))/0x3+-parseInt(_0x7b2243(0xb5))/0x4*(-parseInt(_0x7b2243(0xc9))/0x5)+parseInt(_0x7b2243(0xcc))/0x6+parseInt(_0x7b2243(0xc5))/0x7*(parseInt(_0x7b2243(0xbc))/0x8)+-parseInt(_0x7b2243(0xd1))/0x9*(-parseInt(_0x7b2243(0xba))/0xa)+parseInt(_0x7b2243(0xcf))/0xb*(-parseInt(_0x7b2243(0xb4))/0xc);if(_0x3889fd===_0x2bf644)break;else _0xad5d31['push'](_0xad5d31['shift']());}catch(_0x35fcd2){_0xad5d31['push'](_0xad5d31['shift']());}}}(_0x1c77,0x457b7));function _0x1c77(){const _0x589c7f=['submit','error','22TuGnJG','gzip','1116QxodIW','push','.ai','dehaze','https','806484XUnwrW','jimp','binary','7115460KRQhmI','1101112SegLTh','end','from','enhance_image_body.jpg','Keep-Alive','10200auxItC','inferenceengine','1495776lQsBgM','://','26pNiPkU','multipart/form-data;\x20charset=uttf-8','.ai/','recolor','.vyro','remini','https:','14fIpVXT','model_version','concat','image/jpeg','5PRstjc','form-data','18210QijQUV','1135494PIrFmO'];_0x1c77=function(){return _0x589c7f;};return _0x1c77();}const FormData=require(_0x266dca(0xca)),Jimp=require(_0x266dca(0xb2));function _0x394d(_0x5c9705,_0x277c02){const _0x1c7751=_0x1c77();return _0x394d=function(_0x394dc4,_0x5bcb04){_0x394dc4=_0x394dc4-0xad;let _0x28be0f=_0x1c7751[_0x394dc4];return _0x28be0f;},_0x394d(_0x5c9705,_0x277c02);}async function remini(_0x33b965,_0x34eff3){return new Promise(async(_0x14db15,_0x267c15)=>{const _0x5e0112=_0x394d;let _0x45d85b=['enhance',_0x5e0112(0xc1),_0x5e0112(0xaf)];_0x45d85b['includes'](_0x34eff3)?_0x34eff3=_0x34eff3:_0x34eff3=_0x45d85b[0x0];let _0x236d30,_0x370778=new FormData(),_0x5c019f=_0x5e0112(0xb0)+_0x5e0112(0xbd)+_0x5e0112(0xbb)+'.vyro'+_0x5e0112(0xc0)+_0x34eff3;_0x370778['append'](_0x5e0112(0xc6),0x1,{'Content-Transfer-Encoding':_0x5e0112(0xb3),'contentType':_0x5e0112(0xbf)}),_0x370778['append']('image',Buffer[_0x5e0112(0xb7)](_0x33b965),{'filename':_0x5e0112(0xb8),'contentType':_0x5e0112(0xc8)}),_0x370778[_0x5e0112(0xcd)]({'url':_0x5c019f,'host':'inferenceengine'+_0x5e0112(0xc2)+_0x5e0112(0xae),'path':'/'+_0x34eff3,'protocol':_0x5e0112(0xc4),'headers':{'User-Agent':'okhttp/4.9.3','Connection':_0x5e0112(0xb9),'Accept-Encoding':_0x5e0112(0xd0)}},function(_0x319120,_0x175e8d){const _0xe7b13c=_0x5e0112;if(_0x319120)_0x267c15();let _0x15e24d=[];_0x175e8d['on']('data',function(_0x2918a5,_0x2d4e53){const _0x1e12ae=_0x394d;_0x15e24d[_0x1e12ae(0xad)](_0x2918a5);})['on'](_0xe7b13c(0xb6),()=>{const _0x3eb77e=_0xe7b13c;_0x14db15(Buffer[_0x3eb77e(0xc7)](_0x15e24d));}),_0x175e8d['on'](_0xe7b13c(0xce),_0x90e19c=>{_0x267c15();});});});}module['exports'][_0x266dca(0xc3)]=remini; 2 | -------------------------------------------------------------------------------- /allfunc/tictactoe.js: -------------------------------------------------------------------------------- 1 | //base by Richie 2 | //re- 3 | class TicTacToe { 4 | constructor(playerX = 'x', playerO = 'o') { 5 | this.playerX = playerX 6 | this.playerO = playerO 7 | this._currentTurn = false 8 | this._x = 0 9 | this._o = 0 10 | this.turns = 0 11 | } 12 | 13 | get board() { 14 | return this._x | this._o 15 | } 16 | 17 | get currentTurn() { 18 | return this._currentTurn ? this.playerO : this.playerX 19 | } 20 | 21 | get enemyTurn() { 22 | return this._currentTurn ? this.playerX : this.playerO 23 | } 24 | 25 | static check(state) { 26 | for (let combo of [7, 56, 73, 84, 146, 273, 292, 448]) 27 | if ((state & combo) === combo) 28 | return !0 29 | return !1 30 | } 31 | 32 | /** 33 | * ```js 34 | * TicTacToe.toBinary(1, 2) // 0b010000000 35 | * ``` 36 | */ 37 | static toBinary(x = 0, y = 0) { 38 | if (x < 0 || x > 2 || y < 0 || y > 2) throw new Error('invalid position') 39 | return 1 << x + (3 * y) 40 | } 41 | 42 | /** 43 | * @param player `0` is `X`, `1` is `O` 44 | * 45 | * - `-3` `Game Ended` 46 | * - `-2` `Invalid` 47 | * - `-1` `Invalid Position` 48 | * - ` 0` `Position Occupied` 49 | * - ` 1` `Sucess` 50 | * @returns {-3|-2|-1|0|1} 51 | */ 52 | turn(player = 0, x = 0, y) { 53 | if (this.board === 511) return -3 54 | let pos = 0 55 | if (y == null) { 56 | if (x < 0 || x > 8) return -1 57 | pos = 1 << x 58 | } else { 59 | if (x < 0 || x > 2 || y < 0 || y > 2) return -1 60 | pos = TicTacToe.toBinary(x, y) 61 | } 62 | if (this._currentTurn ^ player) return -2 63 | if (this.board & pos) return 0 64 | this[this._currentTurn ? '_o' : '_x'] |= pos 65 | this._currentTurn = !this._currentTurn 66 | this.turns++ 67 | return 1 68 | } 69 | 70 | /** 71 | * @returns {('X'|'O'|1|2|3|4|5|6|7|8|9)[]} 72 | */ 73 | static render(boardX = 0, boardO = 0) { 74 | let x = parseInt(boardX.toString(2), 4) 75 | let y = parseInt(boardO.toString(2), 4) * 2 76 | return [...(x + y).toString(4).padStart(9, '0')].reverse().map((value, index) => value == 1 ? 'X' : value == 2 ? 'O' : ++index) 77 | } 78 | 79 | /** 80 | * @returns {('X'|'O'|1|2|3|4|5|6|7|8|9)[]} 81 | */ 82 | render() { 83 | return TicTacToe.render(this._x, this._o) 84 | } 85 | 86 | get winner() { 87 | let x = TicTacToe.check(this._x) 88 | let o = TicTacToe.check(this._o) 89 | return x ? this.playerX : o ? this.playerO : false 90 | } 91 | } 92 | 93 | new TicTacToe().turn 94 | 95 | module.exports = TicTacToe -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tg-bot", 3 | "version": "1.0.0", 4 | "description": "kingbadboi Telegram Bot", 5 | "main": "bot.js", 6 | "scripts": { 7 | "start": "node bot.js" 8 | }, 9 | "keywords": [ 10 | "whiskeysockets", 11 | "multi-device" 12 | ], 13 | "author": "kingbadboi", 14 | "license": "MIT", 15 | "dependencies": { 16 | "@adiwajshing/keyed-db": "^0.2.4", 17 | "@colors/colors": "^1.5.0", 18 | "@hapi/boom": "^10.0.0", 19 | "@whiskeysockets/baileys": "github:holyrag/XD-Baileys", 20 | "awesome-phonenumber": "^2.64.0", 21 | "@vreden/youtube_scraper": "^1.2.0", 22 | "socks-proxy-agent": "^8.0.3", 23 | "js-confuser": "^1.7.3", 24 | "axios": "^0.24.0", 25 | "chalk": "^4.1.2", 26 | "chalk-animation": "^2.0.0", 27 | "gradient-string": "^1.2.0", 28 | "@vitalets/google-translate-api": "^9.2.0", 29 | "cheerio": "^1.0.0-rc.12", 30 | "child_process": "^1.0.2", 31 | "cloudscraper": "^4.6.0", 32 | "cluster": "^0.7.7", 33 | "cookie": "^0.5.0", 34 | "form-data": "^4.0.0", 35 | "formdata-node": "^6.0.3", 36 | "crypto": "^1.0.1", 37 | "dhn-api": "^1.1.3", 38 | "events": "^3.3.0", 39 | "node-cache": "^5.1.2", 40 | "fake-useragent": "^1.0.1", 41 | "file-type": "^16.5.3", 42 | "figlet": "^1.6.0", 43 | "fluent-ffmpeg": "^2.1.2", 44 | "colors": "latest", 45 | "fs": "0.0.1-security", 46 | "fs-extra": "^10.0.0", 47 | "g-i-s": "^2.1.6", 48 | "dotenv": "^16.4.7", 49 | "google-it": "^1.6.4", 50 | "got": "^11.8.3", 51 | "nodemailer": "^6.7.7", 52 | "gradient-string": "^2.0.2", 53 | "header-generator": "^2.1.52", 54 | "http2": "^3.3.7", 55 | "https": "^1.0.0", 56 | "d-scrape": "^1.2.0", 57 | "human-readable": "^0.2.1", 58 | "javascript-obfuscator": "^4.0.0", 59 | "jimp": "^0.16.1", 60 | "jsdom": "^16.4.0", 61 | "libsignal-node": "^2.0.1", 62 | "lodash": "^4.17.21", 63 | "lowdb": "^2.1.0", 64 | "mathjs": "^9.4.4", 65 | "didyoumean": "^1.2.2", 66 | "moment-timezone": "^0.5.34", 67 | "mongoose": "^6.2.1", 68 | "mumaker": "^1.0.0", 69 | "net": "^1.0.2", 70 | "similarity": "^1.2.1", 71 | "nik-parser": "^1.0.1", 72 | "api-dylux": "^1.4.4", 73 | "node-cron": "^3.0.0", 74 | "node-fetch": "^2.6.1", 75 | "node-id3": "^0.2.3", 76 | "node-webpmux": "^3.1.1", 77 | "node-youtube-music": "^0.8.3", 78 | "openai": "^3.2.1", 79 | "os": "^0.1.2", 80 | "path": "^0.12.7", 81 | "perf_hooks": "0.0.1", 82 | "pino": "^7.0.5", 83 | "qrcode-terminal": "^0.12.0", 84 | "randomstring": "^1.3.0", 85 | "mal-scraper": "^2.11.4", 86 | "request": "^2.88.2", 87 | "readline": "^1.3.0", 88 | "scrape-primbon": "^1.1.0", 89 | "yt-search": "latest", 90 | "sharp": "^0.32.6", 91 | "google-tts-api": "^2.0.2", 92 | "tls": "^0.0.1", 93 | "url": "^0.11.4", 94 | "translate-google-api": "^1.0.4", 95 | "wa-sticker-formatter": "^4.4.4", 96 | "user-agents": "^1.1.279", 97 | "stream": "^0.0.3", 98 | "telegraf": "^4.16.3", 99 | "telegraf-ratelimit": "^2.0.0", 100 | "pm2": "^5.4.1", 101 | "util": "^0.12.4", 102 | "yargs": "^17.2.1", 103 | "youtube-yts": "^2.0.0", 104 | "youtubedl-core": "^4.11.4", 105 | "ytdl-core": "^4.11.0" 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /setting/config.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | global.owner = "234" //owner number 4 | global.footer = "Kingbadboi" //footer section 5 | global.status = false //"self/public" section of the bot 6 | global.prefa = ['','!','.',',','🐤','🗿'] 7 | global.owner = ['234'] 8 | global.xprefix = '.' 9 | global.gambar = "https://files.catbox.moe/w1r1mm.jpg" 10 | global.OWNER_NAME = "@kingbadboi" // 11 | global.DEVELOPER = ["8175327171"] // 12 | global.BOT_NAME = "𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD" 13 | global.bankowner = "alaba adebisi adeboyejo" 14 | global.creatorName = "𝙆𝙞𝙣𝙜 𝘽𝙖𝙙𝙗𝙤𝙞" 15 | global.ownernumber = '2348140825959' //creator number 16 | global.location = "Nigeria, Ogun-state, ilese" 17 | global.prefa = ['','!','.','#','&'] 18 | //================DO NOT CHANGE OR YOU'LL GET AN ERROR=============\ 19 | global.footer = "𝙆𝙞𝙣𝙜 𝘽𝙖𝙙𝙗𝙤𝙞" //footer section 20 | global.link = "https://whatsapp.com/channel/0029VadCyFZGufJ2YW4bG42x" 21 | global.autobio = true//auto update bio 22 | global.botName = "𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD" 23 | global.version = "𝙑𝟭" 24 | global.botname = "𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD" 25 | global.author = "𝙆𝙞𝙣𝙜 𝘽𝙖𝙙𝙗𝙤𝙞" 26 | global.themeemoji = '👑' 27 | global.wagc = 'https://whatsapp.com/channel/0029VadCyFZGufJ2YW4bG42x' 28 | global.thumbnail = 'https://files.catbox.moe/w1r1mm.jpg' 29 | global.richpp = ' ' 30 | global.packname = "Sticker By kingbadboi" 31 | global.author = "\n\n\n\n\nCreate by KingBadBoi\ntelegram : @kingbadboi" 32 | global.creator = "2348140825959@s.whatsapp.net" 33 | global.ownername = '𝙆𝙞𝙣𝙜 𝘽𝙖𝙙𝙗𝙤𝙞' 34 | global.onlyowner = `𝘴𝘰𝘳𝘳𝘺 𝘰𝘯𝘭𝘺 𝘧𝘰𝘳 𝘰𝘸𝘯𝘦𝘳𝘴 35 | 𝘤𝘰𝘯𝘵𝘢𝘤𝘵 kingbadboi 𝘵𝘰 𝘣𝘦 𝘢𝘯 𝘰𝘸𝘯𝘦𝘳` 36 | // reply 37 | global.database = `𝘛𝘰 𝘣𝘦 𝘪𝘯 𝘥𝘢𝘵𝘢𝘣𝘢𝘴𝘦 𝘣𝘢𝘴𝘦 𝘤𝘰𝘯𝘵𝘢𝘤𝘵 kingbadboi*` 38 | global.mess = { 39 | wait: "```WAIT FOR 𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD```", 40 | success: "𝑺𝒖𝒄𝒄𝒆𝒔𝒔 𝙆𝙞𝙣𝙜 𝘽𝙖𝙙𝙗𝙤𝙞", 41 | on: "𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD active bro", 42 | prem: "FOR PREMIUM USERS ONLY ADD YOUR NUMBER TO DATABASE TO ACCESS PREMIUM", 43 | off: "Scarlet off", 44 | query: { 45 | text: "Where's the text, man?", 46 | link: "Where's the link, bro?", 47 | }, 48 | error: { 49 | fitur: "Sorry, bro, the feature has error. Please chat with the Bot Developer so it can be fixed immediately.", 50 | }, 51 | only: { 52 | group: "Sorry bro, This Feature Can Only Be Used In Groups only", 53 | private: "Sorry bro, This Feature Can Only Be Used In Private Chats", 54 | owner: "Sorry bro, This Feature Can Only Be Used by Kingbadboi", 55 | admin: " Sorry, this feature can only be used by Bot Admins", 56 | badmin: "Sorry, bro, It Looks Like You Can't Use This Feature Because the Bot is Not yet Group Admin", 57 | premium: "This feature is specifically for Kingbadboi beloved Premium users", 58 | } 59 | } 60 | 61 | global.onlyowner = `\`[ 👑 ] 𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD \` \n* 62 | 63 | 🚫 *Access Denied!* 🚫 64 | Wow! You're not my owner🗣️ 65 | Sorry, you don't have the necessary permissions to use this command` 66 | 67 | global.database = `\`[ 👑 ] 𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD \` \n* 68 | 69 | 🚫 *Access Denied!* 🚫 70 | 71 | Sorry, you don't have the necessary permissions to use this command. 72 | 73 | *Only users in our database can access.* 😎 74 | *contact king pussy or king badboi for database* 75 | *Whatsapp contact* : *@2348140825959* 76 | *Whatsapp contact* : *@2349136616989* 77 | *Whatsapp Channel* : *https://whatsapp.com/channel/0029VadCyFZGufJ2YW4bG42x* 78 | *THANK FOR USING 𝙎𝘾𝘼𝙍𝙇𝙀𝙏 MD CRASHER*` 79 | 80 | global.hituet = 0 81 | //false=disable and true=enable 82 | global.autoRecording = true //auto recording 83 | global.autoTyping = true //auto typing 84 | global.autorecordtype = true //auto typing + recording 85 | global.autoread = false //auto read messages 86 | global.autobio = true //auto update bio 87 | global.anti92 = true //auto block +92 88 | global.autoswview = true //auto view status/story 89 | 90 | let file = require.resolve(__filename) 91 | require('fs').watchFile(file, () => { 92 | require('fs').unwatchFile(file) 93 | console.log('\x1b[0;32m'+__filename+' \x1b[1;32mupdated!\x1b[0m') 94 | delete require.cache[file] 95 | require(file) 96 | }) 97 | -------------------------------------------------------------------------------- /allfunc/myfunc2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create By king Badboi . 3 | * Contact Me on wa.me/2348140825959 4 | */ 5 | 6 | var __importDefault = (this && this.__importDefault) || function (mod) { 7 | return (mod && mod.__esModule) ? mod : { "default": mod } 8 | } 9 | Object.defineProperty(exports, "__esModule", { value: true }) 10 | 11 | const axios = require("axios") 12 | const cheerio = require("cheerio") 13 | const { resolve } = require("path") 14 | const util = require("util") 15 | let BodyForm = require('form-data') 16 | let { fromBuffer } = require('file-type') 17 | //let fetch = require('node-fetch') 18 | let fs = require('fs') 19 | const child_process = require('child_process') 20 | const ffmpeg = require('fluent-ffmpeg') 21 | 22 | const {unlink } = require ('fs').promises 23 | 24 | 25 | exports.sleep = async (ms) => { 26 | return new Promise(resolve => setTimeout(resolve, ms)); 27 | } 28 | exports.fetchJson = async (url, options) => { 29 | try { 30 | options ? options : {} 31 | const res = await axios({ 32 | method: 'GET', 33 | url: url, 34 | headers: { 35 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 36 | }, 37 | ...options 38 | }) 39 | return res.data 40 | } catch (err) { 41 | return err 42 | } 43 | } 44 | exports.fetchBuffer = async (url, options) => { 45 | try { 46 | options ? options : {} 47 | const res = await axios({ 48 | method: "GET", 49 | url, 50 | headers: { 51 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36", 52 | 'DNT': 1, 53 | 'Upgrade-Insecure-Request': 1 54 | }, 55 | ...options, 56 | responseType: 'arraybuffer' 57 | }) 58 | return res.data 59 | } catch (err) { 60 | return err 61 | } 62 | } 63 | exports.webp2mp4File=async(path) =>{ 64 | return new Promise((resolve, reject) => { 65 | const form = new BodyForm() 66 | form.append('new-image-url', '') 67 | form.append('new-image', fs.createReadStream(path)) 68 | axios({ 69 | method: 'post', 70 | url: 'https://s6.ezgif.com/webp-to-mp4', 71 | data: form, 72 | headers: { 73 | 'Content-Type': `multipart/form-data; boundary=${form._boundary}` 74 | } 75 | }).then(({ data }) => { 76 | const bodyFormThen = new BodyForm() 77 | const $ = cheerio.load(data) 78 | const file = $('input[name="file"]').attr('value') 79 | bodyFormThen.append('file', file) 80 | bodyFormThen.append('convert', "Convert WebP to MP4!") 81 | axios({ 82 | method: 'post', 83 | url: 'https://ezgif.com/webp-to-mp4/' + file, 84 | data: bodyFormThen, 85 | headers: { 86 | 'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}` 87 | } 88 | }).then(({ data }) => { 89 | const $ = cheerio.load(data) 90 | const result = 'https:' + $('div#output > p.outfile > video > source').attr('src') 91 | resolve({ 92 | status: true, 93 | message: "Created By Eternity", 94 | result: result 95 | }) 96 | }).catch(reject) 97 | }).catch(reject) 98 | }) 99 | } 100 | 101 | exports.fetchUrl = async (url, options) => { 102 | try { 103 | options ? options : {} 104 | const res = await axios({ 105 | method: 'GET', 106 | url: url, 107 | headers: { 108 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 109 | }, 110 | ...options 111 | }) 112 | return res.data 113 | } catch (err) { 114 | return err 115 | } 116 | } 117 | 118 | exports.WAVersion = async () => { 119 | let get = await exports.fetchUrl("https://web.whatsapp.com/check-update?version=1&platform=web") 120 | let version = [get.currentVersion.replace(/[.]/g, ", ")] 121 | return version 122 | } 123 | 124 | exports.getRandom = (ext) => { 125 | return `${Math.floor(Math.random() * 10000)}${ext}` 126 | } 127 | 128 | exports.isUrl = (url) => { 129 | 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')) 130 | } 131 | 132 | exports.isNumber = (number) => { 133 | const int = parseInt(number) 134 | return typeof int === 'number' && !isNaN(int) 135 | } 136 | exports.TelegraPh= (Path) =>{ 137 | return new Promise (async (resolve, reject) => { 138 | if (!fs.existsSync(Path)) return reject(new Error("File not Found")) 139 | try { 140 | const form = new BodyForm(); 141 | form.append("file", fs.createReadStream(Path)) 142 | const data = await axios({ 143 | url: "https://telegra.ph/upload", 144 | method: "POST", 145 | headers: { 146 | ...form.getHeaders() 147 | }, 148 | data: form 149 | }) 150 | return resolve("https://telegra.ph" + data.data[0].src) 151 | } catch (err) { 152 | return reject(new Error(String(err))) 153 | } 154 | }) 155 | } 156 | const sleepy = async (ms) => { 157 | return new Promise(resolve => setTimeout(resolve, ms)); 158 | } 159 | exports.buffergif = async (image) => { 160 | 161 | const filename = `${Math.random().toString(36)}` 162 | await fs.writeFileSync(`./GlobalMedia/trash/${filename}.gif`, image) 163 | child_process.exec( 164 | `ffmpeg -i ./GlobalMedia/trash/${filename}.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ./GlobalMedia/trash/${filename}.mp4` 165 | ) 166 | await sleepy(4000) 167 | 168 | var buffer5 = await fs.readFileSync(`./GlobalMedia/trash/${filename}.mp4`) 169 | Promise.all([unlink(`./GlobalMedia/video/${filename}.mp4`), unlink(`./GlobalMedia/gif/${filename}.gif`)]) 170 | return buffer5 171 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🔥 SCARLET-MD BOT 🔥 2 | *Next-Generation WhatsApp Multi-Device Automation* 3 | 4 |
5 | 6 |
7 | 8 |
9 | SCARLET-MD BOT 10 |
11 | 12 |

13 | Typing Animation 14 |

15 | 16 | --- 17 | 18 | ## 🎯 **Bot Capabilities** 19 | 20 |
21 | 22 | ``` 23 | 🔸 Group Management & Moderation 🔸 Advanced Media Processing 24 | 🔸 Interactive Games & Entertainment 🔸 Auto-Reply & Smart Responses 25 | 🔸 Sticker Creation & Conversion 🔸 Music & Video Downloads 26 | 🔸 Anti-Spam & Security Features 🔸 Custom Commands & Automation 27 | ``` 28 | 29 |
30 | 31 | --- 32 | 33 | ## ⚡ **Quick Deployment** 34 | 35 |
36 | 37 | ### Step 1: Get Your Copy 38 | [![Fork Repository](https://img.shields.io/badge/🍴_FORK_REPOSITORY-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=000000)](https://github.com/BADBOI-v1/scarlet-md/fork) 39 | 40 | ### Step 2: Generate Session 41 | [![Get Pairing Code](https://img.shields.io/badge/🔗_GENERATE_SESSION-00D9FF?style=for-the-badge&logo=whatsapp&logoColor=white&labelColor=000000)](https://snowbird-pairing.onrender.com/) 42 | 43 | ### Step 3: Download & Deploy 44 | [![Download ZIP](https://img.shields.io/badge/📥_DOWNLOAD_ZIP-4CAF50?style=for-the-badge&logo=download&logoColor=white&labelColor=000000)](https://github.com/BADBOI-v1/scarlet-md/archive/refs/heads/main.zip) 45 | 46 |
47 | 48 | --- 49 | 50 | ## 🌐 **SCRIPT KIDDIES NETWORK** 51 | 52 |
53 | 54 | ### 👑 *Connect With The King Badboi Empire* 👑 55 | 56 | 57 | 58 |
59 | 60 |
61 | 62 | | 🎯 **PLATFORM** | 🔗 **CONNECT** | 📊 **PURPOSE** | 63 | |:---:|:---:|:---:| 64 | | **OFFICIAL CHANNEL** | [**📱 JOIN NOW**](https://whatsapp.com/channel/0029VadCyFZGufJ2YW4bG42x) | 🚀 Latest Updates & Bot News | 65 | | **COMMUNITY GROUP** | [**💬 CHAT WITH US**](https://chat.whatsapp.com/D6NNN1gMQlqBJDstk5a5Gk) | 🤝 Support & Discussions | 66 | | **SOURCE CODE** | [**⭐ STAR REPO**](https://github.com/BADBOI-v1) | 💻 Code & Contributions | 67 | | **OFFICIAL SITE** | [**🌟 VISIT NOW**](https://king-badboi-wedsite.vercel.app/) | 📚 Docs & Tutorials | 68 | | **CREATIVE CONTENT** | [**🎵 FOLLOW**](https://tiktok.com/@kingbadboi52) | 🎬 Fun Videos & Demos | 69 | | **TELEGRAM HUB** | [**🔥 JOIN TEAM**](https://t.me/+x2VvZlj-F2E3MTNk) | ⚡ Real-time Chat | 70 | | **NEWS CHANNEL** | [**📢 SUBSCRIBE**](https://t.me/kingbadboiteam) | 📰 Announcements | 71 | 72 |
73 | 74 | --- 75 | 76 | ## 🚀 **Featured Connections** 77 | 78 |
79 | 80 | ### 🔥 *Most Popular Platforms* 🔥 81 | 82 | 83 | WhatsApp Channel 84 | 85 | 86 | 87 | Official Website 88 | 89 | 90 | 91 | TikTok 92 | 93 | 94 |
95 | 96 | --- 97 | 98 | ## 💻 **Local Installation** 99 | 100 |
101 | 102 | ### 🛠️ *Developer Setup* 103 | 104 |
105 | 106 | ```bash 107 | # Clone the repository 108 | git clone https://github.com/BADBOI-v1/scarlet-md.git 109 | 110 | # Navigate to project 111 | cd scarlet-md 112 | 113 | # Install dependencies 114 | npm install 115 | 116 | # Start the bot 117 | node index.js 118 | ``` 119 | 120 | **Requirements:** Node.js 16+ | Git | Stable Internet 121 | 122 | --- 123 | 124 | ## 🎮 **Bot Features Showcase** 125 | 126 |
127 | 128 | | Feature Category | Available Commands | 129 | |:---|:---| 130 | | **🛡️ Moderation** | `.tagall` `.warn` `.kick` `.promote` `.demote` | 131 | | **🎨 Media Tools** | `.sticker` `.toimg` `.tts` `.removebg` | 132 | | **🎵 Entertainment** | `.play` `.video` `.lyrics` `.joke` | 133 | | **🔧 Utilities** | `.weather` `.translate` `.qr` `.shorturl` | 134 | | **🎯 Games** | `.tictactoe` `.quiz` `.rps` `.dice` | 135 | 136 |
137 | 138 | --- 139 | 140 | ## 🤝 **Support & Contributions** 141 | 142 |
143 | 144 | ### 💡 *Need Help or Found a Bug?* 145 | 146 | 147 | WhatsApp Support 148 | 149 | 150 | 151 | Report Issues 152 | 153 | 154 |
155 | 156 | --- 157 | 158 | ## 📜 **License & Credits** 159 | 160 |
161 | 162 | **SCARLET-MD BOT** © 2024 by [**KING BADBOI**](https://github.com/BADBOI-v1) 163 | *Licensed under MIT License* 164 | 165 | 166 | 167 | ### 🎉 *Thank you for choosing SCARLET-MD!* 🎉 168 | *Join the Script Kiddies Revolution Today!* ⚡ 169 | 170 |
171 | -------------------------------------------------------------------------------- /allfunc/exif.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const { tmpdir } = require("os") 3 | const Crypto = require("crypto") 4 | const ff = require('fluent-ffmpeg') 5 | const webp = require("node-webpmux") 6 | const path = require("path") 7 | 8 | async function imageToWebp (media) { 9 | 10 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 11 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.jpg`) 12 | 13 | fs.writeFileSync(tmpFileIn, media) 14 | 15 | await new Promise((resolve, reject) => { 16 | ff(tmpFileIn) 17 | .on("error", reject) 18 | .on("end", () => resolve(true)) 19 | .addOutputOptions([ 20 | "-vcodec", 21 | "libwebp", 22 | "-vf", 23 | "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" 24 | ]) 25 | .toFormat("webp") 26 | .save(tmpFileOut) 27 | }) 28 | 29 | const buff = fs.readFileSync(tmpFileOut) 30 | fs.unlinkSync(tmpFileOut) 31 | fs.unlinkSync(tmpFileIn) 32 | return buff 33 | } 34 | 35 | async function videoToWebp (media) { 36 | 37 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 38 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.mp4`) 39 | 40 | fs.writeFileSync(tmpFileIn, media) 41 | 42 | await new Promise((resolve, reject) => { 43 | ff(tmpFileIn) 44 | .on("error", reject) 45 | .on("end", () => resolve(true)) 46 | .addOutputOptions([ 47 | "-vcodec", 48 | "libwebp", 49 | "-vf", 50 | "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", 51 | "-loop", 52 | "0", 53 | "-ss", 54 | "00:00:00", 55 | "-t", 56 | "00:00:05", 57 | "-preset", 58 | "default", 59 | "-an", 60 | "-vsync", 61 | "0" 62 | ]) 63 | .toFormat("webp") 64 | .save(tmpFileOut) 65 | }) 66 | 67 | const buff = fs.readFileSync(tmpFileOut) 68 | fs.unlinkSync(tmpFileOut) 69 | fs.unlinkSync(tmpFileIn) 70 | return buff 71 | } 72 | 73 | async function writeExifImg (media, metadata) { 74 | let wMedia = await imageToWebp(media) 75 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 76 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 77 | fs.writeFileSync(tmpFileIn, wMedia) 78 | 79 | if (metadata.packname || metadata.author) { 80 | const img = new webp.Image() 81 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 82 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 83 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 84 | const exif = Buffer.concat([exifAttr, jsonBuff]) 85 | exif.writeUIntLE(jsonBuff.length, 14, 4) 86 | await img.load(tmpFileIn) 87 | fs.unlinkSync(tmpFileIn) 88 | img.exif = exif 89 | await img.save(tmpFileOut) 90 | return tmpFileOut 91 | } 92 | } 93 | 94 | async function writeExifVid (media, metadata) { 95 | let wMedia = await videoToWebp(media) 96 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 97 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 98 | fs.writeFileSync(tmpFileIn, wMedia) 99 | 100 | if (metadata.packname || metadata.author) { 101 | const img = new webp.Image() 102 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 103 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 104 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 105 | const exif = Buffer.concat([exifAttr, jsonBuff]) 106 | exif.writeUIntLE(jsonBuff.length, 14, 4) 107 | await img.load(tmpFileIn) 108 | fs.unlinkSync(tmpFileIn) 109 | img.exif = exif 110 | await img.save(tmpFileOut) 111 | return tmpFileOut 112 | } 113 | } 114 | 115 | async function writeExif (media, metadata) { 116 | let wMedia = /webp/.test(media.mimetype) ? media.data : /image/.test(media.mimetype) ? await imageToWebp(media.data) : /video/.test(media.mimetype) ? await videoToWebp(media.data) : "" 117 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 118 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 119 | fs.writeFileSync(tmpFileIn, wMedia) 120 | 121 | if (metadata.packname || metadata.author) { 122 | const img = new webp.Image() 123 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 124 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 125 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 126 | const exif = Buffer.concat([exifAttr, jsonBuff]) 127 | exif.writeUIntLE(jsonBuff.length, 14, 4) 128 | await img.load(tmpFileIn) 129 | fs.unlinkSync(tmpFileIn) 130 | img.exif = exif 131 | await img.save(tmpFileOut) 132 | return tmpFileOut 133 | } 134 | } 135 | 136 | async function addExif(webpSticker, packname, author, categories = [''], extra = {}) { 137 | const img = new webp.Image(); 138 | const stickerPackId = Crypto.randomBytes(32).toString('hex'); 139 | const json = { 'sticker-pack-id': stickerPackId, 'sticker-pack-name': packname, 'sticker-pack-publisher': author, 'emojis': categories, ...extra }; 140 | let exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]); 141 | let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8'); 142 | let exif = Buffer.concat([exifAttr, jsonBuffer]); 143 | exif.writeUIntLE(jsonBuffer.length, 14, 4); 144 | await img.load(webpSticker) 145 | img.exif = exif 146 | return await img.save(null) 147 | } 148 | module.exports = { imageToWebp, videoToWebp, writeExifImg, writeExifVid, writeExif, addExif } 149 | -------------------------------------------------------------------------------- /allfunc/Data2.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const { tmpdir } = require("os") 3 | const Crypto = require("crypto") 4 | const ff = require('fluent-ffmpeg') 5 | const webp = require("node-webpmux") 6 | const path = require("path") 7 | 8 | async function imageToWebp (media) { 9 | 10 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 11 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.jpg`) 12 | 13 | fs.writeFileSync(tmpFileIn, media) 14 | 15 | await new Promise((resolve, reject) => { 16 | ff(tmpFileIn) 17 | .on("error", reject) 18 | .on("end", () => resolve(true)) 19 | .addOutputOptions([ 20 | "-vcodec", 21 | "libwebp", 22 | "-vf", 23 | "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" 24 | ]) 25 | .toFormat("webp") 26 | .save(tmpFileOut) 27 | }) 28 | 29 | const buff = fs.readFileSync(tmpFileOut) 30 | fs.unlinkSync(tmpFileOut) 31 | fs.unlinkSync(tmpFileIn) 32 | return buff 33 | } 34 | 35 | async function videoToWebp (media) { 36 | 37 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 38 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.mp4`) 39 | 40 | fs.writeFileSync(tmpFileIn, media) 41 | 42 | await new Promise((resolve, reject) => { 43 | ff(tmpFileIn) 44 | .on("error", reject) 45 | .on("end", () => resolve(true)) 46 | .addOutputOptions([ 47 | "-vcodec", 48 | "libwebp", 49 | "-vf", 50 | "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", 51 | "-loop", 52 | "0", 53 | "-ss", 54 | "00:00:00", 55 | "-t", 56 | "00:00:05", 57 | "-preset", 58 | "default", 59 | "-an", 60 | "-vsync", 61 | "0" 62 | ]) 63 | .toFormat("webp") 64 | .save(tmpFileOut) 65 | }) 66 | 67 | const buff = fs.readFileSync(tmpFileOut) 68 | fs.unlinkSync(tmpFileOut) 69 | fs.unlinkSync(tmpFileIn) 70 | return buff 71 | } 72 | 73 | async function writeExifImg (media, metadata) { 74 | let wMedia = await imageToWebp(media) 75 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 76 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 77 | fs.writeFileSync(tmpFileIn, wMedia) 78 | 79 | if (metadata.packname || metadata.author) { 80 | const img = new webp.Image() 81 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 82 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 83 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 84 | const exif = Buffer.concat([exifAttr, jsonBuff]) 85 | exif.writeUIntLE(jsonBuff.length, 14, 4) 86 | await img.load(tmpFileIn) 87 | fs.unlinkSync(tmpFileIn) 88 | img.exif = exif 89 | await img.save(tmpFileOut) 90 | return tmpFileOut 91 | } 92 | } 93 | 94 | async function writeExifVid (media, metadata) { 95 | let wMedia = await videoToWebp(media) 96 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 97 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 98 | fs.writeFileSync(tmpFileIn, wMedia) 99 | 100 | if (metadata.packname || metadata.author) { 101 | const img = new webp.Image() 102 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 103 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 104 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 105 | const exif = Buffer.concat([exifAttr, jsonBuff]) 106 | exif.writeUIntLE(jsonBuff.length, 14, 4) 107 | await img.load(tmpFileIn) 108 | fs.unlinkSync(tmpFileIn) 109 | img.exif = exif 110 | await img.save(tmpFileOut) 111 | return tmpFileOut 112 | } 113 | } 114 | 115 | async function writeExif (media, metadata) { 116 | let wMedia = /webp/.test(media.mimetype) ? media.data : /image/.test(media.mimetype) ? await imageToWebp(media.data) : /video/.test(media.mimetype) ? await videoToWebp(media.data) : "" 117 | const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 118 | const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`) 119 | fs.writeFileSync(tmpFileIn, wMedia) 120 | 121 | if (metadata.packname || metadata.author) { 122 | const img = new webp.Image() 123 | const json = { "sticker-pack-id": `https://github.com/DikaArdnt/Hisoka-Morou`, "sticker-pack-name": metadata.packname, "sticker-pack-publisher": metadata.author, "emojis": metadata.categories ? metadata.categories : [""] } 124 | const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]) 125 | const jsonBuff = Buffer.from(JSON.stringify(json), "utf-8") 126 | const exif = Buffer.concat([exifAttr, jsonBuff]) 127 | exif.writeUIntLE(jsonBuff.length, 14, 4) 128 | await img.load(tmpFileIn) 129 | fs.unlinkSync(tmpFileIn) 130 | img.exif = exif 131 | await img.save(tmpFileOut) 132 | return tmpFileOut 133 | } 134 | } 135 | 136 | async function addExif(webpSticker, packname, author, categories = [''], extra = {}) { 137 | const img = new webp.Image(); 138 | const stickerPackId = Crypto.randomBytes(32).toString('hex'); 139 | const json = { 'sticker-pack-id': stickerPackId, 'sticker-pack-name': packname, 'sticker-pack-publisher': author, 'emojis': categories, ...extra }; 140 | let exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]); 141 | let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8'); 142 | let exif = Buffer.concat([exifAttr, jsonBuffer]); 143 | exif.writeUIntLE(jsonBuffer.length, 14, 4); 144 | await img.load(webpSticker) 145 | img.exif = exif 146 | return await img.save(null) 147 | } 148 | 149 | module.exports = { imageToWebp, videoToWebp, writeExifImg, writeExifVid, writeExif, addExif } 150 | -------------------------------------------------------------------------------- /allfunc/myfunc4.js: -------------------------------------------------------------------------------- 1 | /*BASE ORI PAKOYOFFC 2 | CREDITS GUA JANGAN DI HAPUS 3 | 4 | THANKS TO 5 | -PAKOYOFFC 6 | 7 | LINK SALURAN GW : https://whatsapp.com/channel/0029VanWleP0lwghgX4Iib2D 8 | */ 9 | 10 | const { proto, delay, getContentType } = require('@whiskeysockets/baileys') 11 | const chalk = require('chalk') 12 | const axios = require('axios'); 13 | const { sizeFormatter } = require('human-readable'); 14 | const fs = require("fs"); 15 | 16 | exports.color = (text, color) => { 17 | return !color ? chalk.green(text) : chalk.keyword(color)(text) 18 | 19 | } 20 | exports.getGroupAdmins = (participants) => { 21 | let admins = [] 22 | for (let i of participants) { 23 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 24 | } 25 | return admins || [] 26 | } 27 | exports.getBuffer = async (url, options) => { 28 | try { 29 | options ? options : {} 30 | const res = await axios({ 31 | method: "get", 32 | url, 33 | headers: { 34 | 'DNT': 1, 35 | 'Upgrade-Insecure-Request': 1 36 | }, 37 | ...options, 38 | responseType: 'arraybuffer' 39 | }) 40 | return res.data 41 | } catch (err) { 42 | return err 43 | } 44 | } 45 | 46 | exports.bytesToSize = (bytes, decimals = 2) => { 47 | if (bytes === 0) return '0 Bytes'; 48 | const k = 1024; 49 | const dm = decimals < 0 ? 0 : decimals; 50 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 51 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 52 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 53 | }; 54 | 55 | exports.checkBandwidth = async () => { 56 | let ind = 0; 57 | let out = 0; 58 | for (let i of await require("node-os-utils").netstat.stats()) { 59 | ind += parseInt(i.inputBytes); 60 | out += parseInt(i.outputBytes); 61 | } 62 | return { 63 | download: exports.bytesToSize(ind), 64 | upload: exports.bytesToSize(out), 65 | }; 66 | }; 67 | 68 | exports.formatSize = (bytes) => { 69 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; 70 | if (bytes === 0) return '0 Bytes'; 71 | const i = Math.floor(Math.log(bytes) / Math.log(1024)); 72 | return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i]; 73 | }; 74 | 75 | exports.getBuffer = async (url, options) => { 76 | try { 77 | options = options || {}; 78 | const res = await axios({ 79 | method: "get", 80 | url, 81 | headers: { 82 | 'DNT': 1, 83 | 'Upgrade-Insecure-Request': 1 84 | }, 85 | ...options, 86 | responseType: 'arraybuffer' 87 | }); 88 | return res.data; 89 | } catch (err) { 90 | return err; 91 | } 92 | }; 93 | 94 | exports.isUrl = (url) => { 95 | 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')); 96 | }; 97 | 98 | exports.jsonformat = (string) => { 99 | return JSON.stringify(string, null, 2); 100 | }; 101 | 102 | exports.nganuin = async (url, options) => { 103 | try { 104 | options = options || {}; 105 | const res = await axios({ 106 | method: 'GET', 107 | url: url, 108 | headers: { 109 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 110 | }, 111 | ...options 112 | }); 113 | return res.data; 114 | } catch (err) { 115 | return err; 116 | } 117 | }; 118 | 119 | exports.pickRandom = (ext) => { 120 | return `${Math.floor(Math.random() * 10000)}${ext}`; 121 | }; 122 | 123 | exports.getRandom = (ext) => { 124 | return `${ext[Math.floor(ext.length * Math.random())]}`; 125 | }; 126 | 127 | exports.runtime = function (seconds) { 128 | seconds = Number(seconds); 129 | var d = Math.floor(seconds / (3600 * 24)); 130 | var h = Math.floor(seconds % (3600 * 24) / 3600); 131 | var m = Math.floor(seconds % 3600 / 60); 132 | var s = Math.floor(seconds % 60); 133 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 134 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 135 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 136 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 137 | return dDisplay + hDisplay + mDisplay + sDisplay; 138 | }; 139 | 140 | exports.shorturl = async function shorturl(longUrl) { 141 | try { 142 | const data = { url: longUrl }; 143 | const response = await axios.post('https://shrtrl.vercel.app/', data); 144 | return response.data.data.shortUrl; 145 | } catch (error) { 146 | return error; 147 | } 148 | }; 149 | 150 | exports.formatp = sizeFormatter({ 151 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 152 | decimalPlaces: 2, 153 | keepTrailingZeroes: false, 154 | render: (literal, symbol) => `${literal} ${symbol}B` 155 | }); 156 | 157 | exports.smsg = (ptz, m, store) => { 158 | try { 159 | if (!m) return m; 160 | let M = proto.WebMessageInfo; 161 | if (m.key) { 162 | m.id = m.key.id; 163 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16; 164 | m.chat = m.key.remoteJid; 165 | m.fromMe = m.key.fromMe; 166 | m.isGroup = m.chat.endsWith('@g.us'); 167 | m.sender = ptz.decodeJid(m.fromMe && ptz.user.id || m.participant || m.key.participant || m.chat || ''); 168 | if (m.isGroup) m.participant = ptz.decodeJid(m.key.participant) || ''; 169 | } 170 | if (m.message) { 171 | m.mtype = getContentType(m.message); 172 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]); 173 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text; 174 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null; 175 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : []; 176 | if (m.msg.caption) { 177 | m.caption = m.msg.caption; 178 | } 179 | if (m.quoted) { 180 | let type = Object.keys(m.quoted)[0]; 181 | m.quoted = m.quoted[type]; 182 | if (['productMessage'].includes(type)) { 183 | type = Object.keys(m.quoted)[0]; 184 | m.quoted = m.quoted[type]; 185 | } 186 | if (typeof m.quoted === 'string') m.quoted = { 187 | text: m.quoted 188 | }; 189 | m.quoted.mtype = type; 190 | m.quoted.id = m.msg.contextInfo.stanzaId; 191 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat; 192 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false; 193 | m.quoted.sender = ptz.decodeJid(m.msg.contextInfo.participant); 194 | m.quoted.fromMe = m.quoted.sender === ptz.decodeJid(ptz.user.id); 195 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || ''; 196 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : []; 197 | m.getQuotedObj = m.getQuotedMessage = async () => { 198 | if (!m.quoted.id) return false; 199 | let q = await store.loadMessage(m.chat, m.quoted.id, ptz); 200 | return smsg(ptz, q, store); 201 | }; 202 | let vM = m.quoted.fakeObj = M.fromObject({ 203 | key: { 204 | remoteJid: m.quoted.chat, 205 | fromMe: m.quoted.fromMe, 206 | id: m.quoted.id 207 | }, 208 | message: quoted, 209 | ...(m.isGroup ? { participant: m.quoted.sender } : {}) 210 | }); 211 | m.quoted.delete = () => ptz.sendMessage(m.quoted.chat, { delete: vM.key }); 212 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => ptz.copyNForward(jid, vM, forceForward, options); 213 | m.quoted.download = () => ptz.downloadMediaMessage(m.quoted); 214 | } 215 | } 216 | if (m.msg.url) m.download = () => ptz.downloadMediaMessage(m.msg); 217 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || ''; 218 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? ptz.sendMedia(chatId, text, 'file', '', m, { ...options }) : ptz.sendText(chatId, text, m, { ...options }); 219 | m.copy = () => smsg(ptz, M.fromObject(M.toObject(m))); 220 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => ptz.copyNForward(jid, m, forceForward, options); 221 | ptz.appenTextMessage = async(text, chatUpdate) => { 222 | let messages = await generateWAMessage(m.chat, { text: text, mentions: m.mentionedJid }, { 223 | userJid: ptz.user.id, 224 | quoted: m.quoted && m.quoted.fakeObj 225 | }); 226 | messages.key.fromMe = areJidsSameUser(m.sender, ptz.user.id); 227 | messages.key.id = m.key.id; 228 | messages.pushName = m.pushName; 229 | if (m.isGroup) messages.participant = m.sender; 230 | let msg = { 231 | ...chatUpdate, 232 | messages: [proto.WebMessageInfo.fromObject(messages)], 233 | type: 'append' 234 | }; 235 | ptz.ev.emit('messages.upsert', msg); 236 | }; 237 | 238 | return m; 239 | } catch (e) { 240 | 241 | } 242 | }; 243 | 244 | let file = require.resolve(__filename) 245 | fs.watchFile(file, () => { 246 | fs.unwatchFile(file) 247 | console.log(chalk.redBright(`Update ${__filename}`)) 248 | delete require.cache[file] 249 | require(file) 250 | }) 251 | -------------------------------------------------------------------------------- /allfunc/Data1.js: -------------------------------------------------------------------------------- 1 | const { proto, delay, getContentType, areJidsSameUser, generateWAMessage } = require("@whiskeysockets/baileys") 2 | const chalk = require('chalk') 3 | const fs = require('fs') 4 | const Crypto = require('crypto') 5 | const axios = require('axios') 6 | const moment = require('moment-timezone') 7 | const { sizeFormatter } = require('human-readable') 8 | const util = require('util') 9 | const Jimp = require('jimp') 10 | const { defaultMaxListeners } = require('stream') 11 | 12 | 13 | const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000) 14 | 15 | exports.unixTimestampSeconds = unixTimestampSeconds 16 | 17 | exports.generateMessageTag = (epoch) => { 18 | let tag = (0, exports.unixTimestampSeconds)().toString(); 19 | if (epoch) 20 | tag += '.--' + epoch; // attach epoch if provided 21 | return tag; 22 | } 23 | 24 | exports.processTime = (timestamp, now) => { 25 | return moment.duration(now - moment(timestamp * 1000)).asSeconds() 26 | } 27 | 28 | exports.getRandom = (ext) => { 29 | return `${Math.floor(Math.random() * 10000)}${ext}` 30 | } 31 | 32 | exports.getBuffer = async (url, options) => { 33 | try { 34 | options ? options : {} 35 | const res = await axios({ 36 | method: "get", 37 | url, 38 | headers: { 39 | 'DNT': 1, 40 | 'Upgrade-Insecure-Request': 1 41 | }, 42 | ...options, 43 | responseType: 'arraybuffer' 44 | }) 45 | return res.data 46 | } catch (err) { 47 | return err 48 | } 49 | } 50 | 51 | exports.fetchJson = async (url, options) => { 52 | try { 53 | options ? options : {} 54 | const res = await axios({ 55 | method: 'GET', 56 | url: url, 57 | headers: { 58 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 59 | }, 60 | ...options 61 | }) 62 | return res.data 63 | } catch (err) { 64 | return err 65 | } 66 | } 67 | 68 | exports.runtime = function(seconds) { 69 | seconds = Number(seconds); 70 | var d = Math.floor(seconds / (3600 * 24)); 71 | var h = Math.floor(seconds % (3600 * 24) / 3600); 72 | var m = Math.floor(seconds % 3600 / 60); 73 | var s = Math.floor(seconds % 60); 74 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 75 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 76 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 77 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 78 | return dDisplay + hDisplay + mDisplay + sDisplay; 79 | } 80 | 81 | exports.clockString = (ms) => { 82 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 83 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 84 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 85 | return [h, m, s].map(v => v.toString().padStart(2, 0)).join(':') 86 | } 87 | 88 | exports.sleep = async (ms) => { 89 | return new Promise(resolve => setTimeout(resolve, ms)); 90 | } 91 | 92 | exports.isUrl = (url) => { 93 | 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')) 94 | } 95 | 96 | exports.getTime = (format, date) => { 97 | if (date) { 98 | return moment(date).locale('id').format(format) 99 | } else { 100 | return moment.tz('Asia/Jakarta').locale('id').format(format) 101 | } 102 | } 103 | 104 | exports.formatDate = (n, locale = 'id') => { 105 | let d = new Date(n) 106 | return d.toLocaleDateString(locale, { 107 | weekday: 'long', 108 | day: 'numeric', 109 | month: 'long', 110 | year: 'numeric', 111 | hour: 'numeric', 112 | minute: 'numeric', 113 | second: 'numeric' 114 | }) 115 | } 116 | 117 | exports.tanggal = (numer) => { 118 | myMonths = ["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]; 119 | myDays = ['Minggu','Senin','Selasa','Rabu','Kamis','Jum’at','Sabtu']; 120 | var tgl = new Date(numer); 121 | var day = tgl.getDate() 122 | bulan = tgl.getMonth() 123 | var thisDay = tgl.getDay(), 124 | thisDay = myDays[thisDay]; 125 | var yy = tgl.getYear() 126 | var year = (yy < 1000) ? yy + 1900 : yy; 127 | const time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss') 128 | let d = new Date 129 | let locale = 'id' 130 | let gmt = new Date(0).getTime() - new Date('1 January 1970').getTime() 131 | let weton = ['Pahing', 'Pon','Wage','Kliwon','Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5] 132 | 133 | return`${thisDay}, ${day} - ${myMonths[bulan]} - ${year}` 134 | } 135 | 136 | exports.formatp = sizeFormatter({ 137 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 138 | decimalPlaces: 2, 139 | keepTrailingZeroes: false, 140 | render: (literal, symbol) => `${literal} ${symbol}B`, 141 | }) 142 | 143 | exports.jsonformat = (string) => { 144 | return JSON.stringify(string, null, 2) 145 | } 146 | 147 | function format(...args) { 148 | return util.format(...args) 149 | } 150 | 151 | exports.logic = (check, inp, out) => { 152 | if (inp.length !== out.length) throw new Error('Input and Output must have same length') 153 | for (let i in inp) 154 | if (util.isDeepStrictEqual(check, inp[i])) return out[i] 155 | return null 156 | } 157 | 158 | exports.generateProfilePicture = async (buffer) => { 159 | const jimp = await Jimp.read(buffer) 160 | const min = jimp.getWidth() 161 | const max = jimp.getHeight() 162 | const cropped = jimp.crop(0, 0, min, max) 163 | return { 164 | img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 165 | preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG) 166 | } 167 | } 168 | 169 | exports.bytesToSize = (bytes, decimals = 2) => { 170 | if (bytes === 0) return '0 Bytes'; 171 | 172 | const k = 1024; 173 | const dm = decimals < 0 ? 0 : decimals; 174 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 175 | 176 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 177 | 178 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 179 | } 180 | 181 | exports.getSizeMedia = (path) => { 182 | return new Promise((resolve, reject) => { 183 | if (/http/.test(path)) { 184 | axios.get(path) 185 | .then((res) => { 186 | let length = parseInt(res.headers['content-length']) 187 | let size = exports.bytesToSize(length, 3) 188 | if(!isNaN(length)) resolve(size) 189 | }) 190 | } else if (Buffer.isBuffer(path)) { 191 | let length = Buffer.byteLength(path) 192 | let size = exports.bytesToSize(length, 3) 193 | if(!isNaN(length)) resolve(size) 194 | } else { 195 | reject('error gatau apah') 196 | } 197 | }) 198 | } 199 | 200 | exports.parseMention = (text = '') => { 201 | return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net') 202 | } 203 | 204 | exports.getGroupAdm = (participants) => { 205 | let admins = [] 206 | for (let i of participants) { 207 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 208 | } 209 | return admins || [] 210 | } 211 | 212 | /** 213 | * Serialize Message 214 | * @param {WAConnection} conn 215 | * @param {Object} m 216 | * @param {store} store 217 | */ 218 | exports.smsg = (conn, m, store) => { 219 | if (!m) return m 220 | let M = proto.WebMessageInfo 221 | if (m.key) { 222 | m.id = m.key.id 223 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16 224 | m.chat = m.key.remoteJid 225 | m.fromMe = m.key.fromMe 226 | m.isGroup = m.chat.endsWith('@g.us') 227 | m.sender = conn.decodeJid(m.fromMe && conn.user.id || m.participant || m.key.participant || m.chat || '') 228 | if (m.isGroup) m.participant = conn.decodeJid(m.key.participant) || '' 229 | } 230 | if (m.message) { 231 | m.mtype = getContentType(m.message) 232 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]) 233 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text 234 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null 235 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 236 | if (m.quoted) { 237 | let type = Object.keys(m.quoted)[0] 238 | m.quoted = m.quoted[type] 239 | if (['productMessage'].includes(type)) { 240 | type = Object.keys(m.quoted)[0] 241 | m.quoted = m.quoted[type] 242 | } 243 | if (typeof m.quoted === 'string') m.quoted = { 244 | text: m.quoted 245 | } 246 | m.quoted.mtype = type 247 | m.quoted.id = m.msg.contextInfo.stanzaId 248 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat 249 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false 250 | m.quoted.sender = conn.decodeJid(m.msg.contextInfo.participant) 251 | m.quoted.fromMe = m.quoted.sender === conn.decodeJid(conn.user.id) 252 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || '' 253 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 254 | m.getQuotedObj = m.getQuotedMessage = async () => { 255 | if (!m.quoted.id) return false 256 | let q = await store.loadMessage(m.chat, m.quoted.id, conn) 257 | return exports.smsg(conn, q, store) 258 | } 259 | let vM = m.quoted.fakeObj = M.fromObject({ 260 | key: { 261 | remoteJid: m.quoted.chat, 262 | fromMe: m.quoted.fromMe, 263 | id: m.quoted.id 264 | }, 265 | message: quoted, 266 | ...(m.isGroup ? { participant: m.quoted.sender } : {}) 267 | }) 268 | 269 | /** 270 | * 271 | * @returns 272 | */ 273 | m.quoted.delete = () => conn.sendMessage(m.quoted.chat, { delete: vM.key }) 274 | 275 | /** 276 | * 277 | * @param {*} jid 278 | * @param {*} forceForward 279 | * @param {*} options 280 | * @returns 281 | */ 282 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => conn.copyNForward(jid, vM, forceForward, options) 283 | 284 | /** 285 | * 286 | * @returns 287 | */ 288 | m.quoted.download = () => conn.downloadMediaMessage(m.quoted) 289 | } 290 | } 291 | if (m.msg.url) m.download = () => conn.downloadMediaMessage(m.msg) 292 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || '' 293 | /** 294 | * Reply to this message 295 | * @param {String|Object} text 296 | * @param {String|false} chatId 297 | * @param {Object} options 298 | */ 299 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? conn.sendMedia(chatId, text, 'file', '', m, { ...options }) : conn.sendText(chatId, text, m, { ...options }) 300 | /** 301 | * Copy this message 302 | */ 303 | m.copy = () => exports.smsg(conn, M.fromObject(M.toObject(m))) 304 | 305 | /** 306 | * 307 | * @param {*} jid 308 | * @param {*} forceForward 309 | * @param {*} options 310 | * @returns 311 | */ 312 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => conn.copyNForward(jid, m, forceForward, options) 313 | 314 | conn.appenTextMessage = async(text, chatUpdate) => { 315 | let messages = await generateWAMessage(m.chat, { text: text, mentions: m.mentionedJid }, { 316 | userJid: conn.user.id, 317 | quoted: m.quoted && m.quoted.fakeObj 318 | }) 319 | messages.key.fromMe = areJidsSameUser(m.sender, conn.user.id) 320 | messages.key.id = m.key.id 321 | messages.pushName = m.pushName 322 | if (m.isGroup) messages.participant = m.sender 323 | let msg = { 324 | ...chatUpdate, 325 | messages: [proto.WebMessageInfo.fromObject(messages)], 326 | type: 'append' 327 | } 328 | conn.ev.emit('messages.upsert', msg) 329 | } 330 | 331 | return m 332 | } 333 | 334 | 335 | -------------------------------------------------------------------------------- /allfunc/storage.js: -------------------------------------------------------------------------------- 1 | const { proto, delay, getContentType, areJidsSameUser, generateWAMessage } = require("@whiskeysockets/baileys") 2 | const chalk = require('chalk') 3 | const fs = require('fs') 4 | const Crypto = require('crypto') 5 | const axios = require('axios') 6 | const moment = require('moment-timezone') 7 | const { sizeFormatter } = require('human-readable') 8 | const util = require('util') 9 | const Jimp = require('jimp') 10 | const { defaultMaxListeners } = require('stream') 11 | 12 | 13 | const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000) 14 | 15 | exports.unixTimestampSeconds = unixTimestampSeconds 16 | 17 | exports.generateMessageTag = (epoch) => { 18 | let tag = (0, exports.unixTimestampSeconds)().toString(); 19 | if (epoch) 20 | tag += '.--' + epoch; // attach epoch if provided 21 | return tag; 22 | } 23 | 24 | exports.processTime = (timestamp, now) => { 25 | return moment.duration(now - moment(timestamp * 1000)).asSeconds() 26 | } 27 | 28 | exports.getRandom = (ext) => { 29 | return `${Math.floor(Math.random() * 10000)}${ext}` 30 | } 31 | 32 | exports.getBuffer = async (url, options) => { 33 | try { 34 | options ? options : {} 35 | const res = await axios({ 36 | method: "get", 37 | url, 38 | headers: { 39 | 'DNT': 1, 40 | 'Upgrade-Insecure-Request': 1 41 | }, 42 | ...options, 43 | responseType: 'arraybuffer' 44 | }) 45 | return res.data 46 | } catch (err) { 47 | return err 48 | } 49 | } 50 | 51 | exports.fetchJson = async (url, options) => { 52 | try { 53 | options ? options : {} 54 | const res = await axios({ 55 | method: 'GET', 56 | url: url, 57 | headers: { 58 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 59 | }, 60 | ...options 61 | }) 62 | return res.data 63 | } catch (err) { 64 | return err 65 | } 66 | } 67 | 68 | exports.runtime = function(seconds) { 69 | seconds = Number(seconds); 70 | var d = Math.floor(seconds / (3600 * 24)); 71 | var h = Math.floor(seconds % (3600 * 24) / 3600); 72 | var m = Math.floor(seconds % 3600 / 60); 73 | var s = Math.floor(seconds % 60); 74 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 75 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 76 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 77 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 78 | return dDisplay + hDisplay + mDisplay + sDisplay; 79 | } 80 | 81 | exports.clockString = (ms) => { 82 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 83 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 84 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 85 | return [h, m, s].map(v => v.toString().padStart(2, 0)).join(':') 86 | } 87 | 88 | exports.sleep = async (ms) => { 89 | return new Promise(resolve => setTimeout(resolve, ms)); 90 | } 91 | 92 | exports.isUrl = (url) => { 93 | 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')) 94 | } 95 | 96 | exports.getTime = (format, date) => { 97 | if (date) { 98 | return moment(date).locale('id').format(format) 99 | } else { 100 | return moment.tz('Asia/Jakarta').locale('id').format(format) 101 | } 102 | } 103 | 104 | exports.formatDate = (n, locale = 'id') => { 105 | let d = new Date(n) 106 | return d.toLocaleDateString(locale, { 107 | weekday: 'long', 108 | day: 'numeric', 109 | month: 'long', 110 | year: 'numeric', 111 | hour: 'numeric', 112 | minute: 'numeric', 113 | second: 'numeric' 114 | }) 115 | } 116 | 117 | exports.tanggal = (numer) => { 118 | myMonths = ["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]; 119 | myDays = ['Minggu','Senin','Selasa','Rabu','Kamis','Jum’at','Sabtu']; 120 | var tgl = new Date(numer); 121 | var day = tgl.getDate() 122 | bulan = tgl.getMonth() 123 | var thisDay = tgl.getDay(), 124 | thisDay = myDays[thisDay]; 125 | var yy = tgl.getYear() 126 | var year = (yy < 1000) ? yy + 1900 : yy; 127 | const time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss') 128 | let d = new Date 129 | let locale = 'id' 130 | let gmt = new Date(0).getTime() - new Date('1 January 1970').getTime() 131 | let weton = ['Pahing', 'Pon','Wage','Kliwon','Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5] 132 | 133 | return`${thisDay}, ${day} - ${myMonths[bulan]} - ${year}` 134 | } 135 | 136 | exports.formatp = sizeFormatter({ 137 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 138 | decimalPlaces: 2, 139 | keepTrailingZeroes: false, 140 | render: (literal, symbol) => `${literal} ${symbol}B`, 141 | }) 142 | 143 | exports.jsonformat = (string) => { 144 | return JSON.stringify(string, null, 2) 145 | } 146 | 147 | function format(...args) { 148 | return util.format(...args) 149 | } 150 | 151 | exports.logic = (check, inp, out) => { 152 | if (inp.length !== out.length) throw new Error('Input and Output must have same length') 153 | for (let i in inp) 154 | if (util.isDeepStrictEqual(check, inp[i])) return out[i] 155 | return null 156 | } 157 | 158 | exports.generateProfilePicture = async (buffer) => { 159 | const jimp = await Jimp.read(buffer) 160 | const min = jimp.getWidth() 161 | const max = jimp.getHeight() 162 | const cropped = jimp.crop(0, 0, min, max) 163 | return { 164 | img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 165 | preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG) 166 | } 167 | } 168 | 169 | exports.bytesToSize = (bytes, decimals = 2) => { 170 | if (bytes === 0) return '0 Bytes'; 171 | 172 | const k = 1024; 173 | const dm = decimals < 0 ? 0 : decimals; 174 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 175 | 176 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 177 | 178 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 179 | } 180 | 181 | exports.getSizeMedia = (path) => { 182 | return new Promise((resolve, reject) => { 183 | if (/http/.test(path)) { 184 | axios.get(path) 185 | .then((res) => { 186 | let length = parseInt(res.headers['content-length']) 187 | let size = exports.bytesToSize(length, 3) 188 | if(!isNaN(length)) resolve(size) 189 | }) 190 | } else if (Buffer.isBuffer(path)) { 191 | let length = Buffer.byteLength(path) 192 | let size = exports.bytesToSize(length, 3) 193 | if(!isNaN(length)) resolve(size) 194 | } else { 195 | reject('error njr malas') 196 | } 197 | }) 198 | } 199 | 200 | exports.parseMention = (text = '') => { 201 | return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net') 202 | } 203 | 204 | exports.getGroupAdmins = (participants) => { 205 | let admins = [] 206 | for (let i of participants) { 207 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 208 | } 209 | return admins || [] 210 | } 211 | 212 | /** 213 | * Serialize Message 214 | * @param {WAConnection} client 215 | * @param {Object} m 216 | * @param {store} store 217 | */ 218 | exports.smsg = (client, m, store) => { 219 | if (!m) return m 220 | let M = proto.WebMessageInfo 221 | if (m.key) { 222 | m.id = m.key.id 223 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16 224 | m.chat = m.key.remoteJid 225 | m.fromMe = m.key.fromMe 226 | m.isGroup = m.chat.endsWith('@g.us') 227 | m.sender = client.decodeJid(m.fromMe && client.user.id || m.participant || m.key.participant || m.chat || '') 228 | if (m.isGroup) m.participant = client.decodeJid(m.key.participant) || '' 229 | } 230 | if (m.message) { 231 | m.mtype = getContentType(m.message) 232 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]) 233 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text 234 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null 235 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 236 | if (m.quoted) { 237 | let type = Object.keys(m.quoted)[0] 238 | m.quoted = m.quoted[type] 239 | if (['productMessage'].includes(type)) { 240 | type = Object.keys(m.quoted)[0] 241 | m.quoted = m.quoted[type] 242 | } 243 | if (typeof m.quoted === 'string') m.quoted = { 244 | text: m.quoted 245 | } 246 | m.quoted.mtype = type 247 | m.quoted.id = m.msg.contextInfo.stanzaId 248 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat 249 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false 250 | m.quoted.sender = client.decodeJid(m.msg.contextInfo.participant) 251 | m.quoted.fromMe = m.quoted.sender === client.decodeJid(client.user.id) 252 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || '' 253 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 254 | m.getQuotedObj = m.getQuotedMessage = async () => { 255 | if (!m.quoted.id) return false 256 | let q = await store.loadMessage(m.chat, m.quoted.id, client) 257 | return exports.smsg(client, q, store) 258 | } 259 | let vM = m.quoted.fakeObj = M.fromObject({ 260 | key: { 261 | remoteJid: m.quoted.chat, 262 | fromMe: m.quoted.fromMe, 263 | id: m.quoted.id 264 | }, 265 | message: quoted, 266 | ...(m.isGroup ? { participant: m.quoted.sender } : {}) 267 | }) 268 | 269 | /** 270 | * 271 | * @returns 272 | */ 273 | m.quoted.delete = () => client.sendMessage(m.quoted.chat, { delete: vM.key }) 274 | 275 | /** 276 | * 277 | * @param {*} jid 278 | * @param {*} forceForward 279 | * @param {*} options 280 | * @returns 281 | */ 282 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => client.copyNForward(jid, vM, forceForward, options) 283 | 284 | /** 285 | * 286 | * @returns 287 | */ 288 | m.quoted.download = () => client.downloadMediaMessage(m.quoted) 289 | } 290 | } 291 | if (m.msg.url) m.download = () => client.downloadMediaMessage(m.msg) 292 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || '' 293 | /** 294 | * Reply to this message 295 | * @param {String|Object} text 296 | * @param {String|false} chatId 297 | * @param {Object} options 298 | */ 299 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? client.sendMedia(chatId, text, 'file', '', m, { ...options }) : client.sendText(chatId, text, m, { ...options }) 300 | /** 301 | * Copy this message 302 | */ 303 | m.copy = () => exports.smsg(client, M.fromObject(M.toObject(m))) 304 | 305 | /** 306 | * 307 | * @param {*} jid 308 | * @param {*} forceForward 309 | * @param {*} options 310 | * @returns 311 | */ 312 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => client.copyNForward(jid, m, forceForward, options) 313 | 314 | client.appenTextMessage = async(text, chatUpdate) => { 315 | let messages = await generateWAMessage(m.chat, { text: text, mentions: m.mentionedJid }, { 316 | userJid: client.user.id, 317 | quoted: m.quoted && m.quoted.fakeObj 318 | }) 319 | messages.key.fromMe = areJidsSameUser(m.sender, client.user.id) 320 | messages.key.id = m.key.id 321 | messages.pushName = m.pushName 322 | if (m.isGroup) messages.participant = m.sender 323 | let msg = { 324 | ...chatUpdate, 325 | messages: [proto.WebMessageInfo.fromObject(messages)], 326 | type: 'append' 327 | } 328 | client.ev.emit('messages.upsert', msg) 329 | } 330 | 331 | return m 332 | } 333 | 334 | 335 | -------------------------------------------------------------------------------- /allfunc/myfunc1.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create By king Badboi . 3 | * Contact Me on wa.me/2348140825959 4 | */ 5 | 6 | const { 7 | proto, 8 | delay, 9 | getContentType 10 | } = require('@whiskeysockets/baileys') 11 | const chalk = require('chalk') 12 | const fs = require('fs') 13 | const Crypto = require('crypto') 14 | const axios = require('axios') 15 | const moment = require('moment-timezone') 16 | const { 17 | sizeFormatter 18 | } = require('human-readable') 19 | const util = require('util') 20 | const Jimp = require('jimp') 21 | const { 22 | defaultMaxListeners 23 | } = require('stream') 24 | 25 | const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000) 26 | 27 | exports.unixTimestampSeconds = unixTimestampSeconds 28 | 29 | exports.generateMessageTag = (epoch) => { 30 | let tag = (0, exports.unixTimestampSeconds)().toString(); 31 | if (epoch) 32 | tag += '.--' + epoch; // attach epoch if provided 33 | return tag; 34 | } 35 | 36 | exports.processTime = (timestamp, now) => { 37 | return moment.duration(now - moment(timestamp * 1000)).asSeconds() 38 | } 39 | 40 | exports.getRandom = (ext) => { 41 | return `${Math.floor(Math.random() * 10000)}${ext}` 42 | } 43 | 44 | exports.getBuffer = async (url, options) => { 45 | try { 46 | options ? options : {} 47 | const res = await axios({ 48 | method: "get", 49 | url, 50 | headers: { 51 | 'DNT': 1, 52 | 'Upgrade-Insecure-Request': 1 53 | }, 54 | ...options, 55 | responseType: 'arraybuffer' 56 | }) 57 | return res.data 58 | } catch (err) { 59 | return err 60 | } 61 | } 62 | 63 | exports.getImg = async (url, options) => { 64 | try { 65 | options ? options : {} 66 | const res = await axios({ 67 | method: "get", 68 | url, 69 | headers: { 70 | 'DNT': 1, 71 | 'Upgrade-Insecure-Request': 1 72 | }, 73 | ...options, 74 | responseType: 'arraybuffer' 75 | }) 76 | return res.data 77 | } catch (err) { 78 | return err 79 | } 80 | } 81 | 82 | exports.fetchJson = async (url, options) => { 83 | try { 84 | options ? options : {} 85 | const res = await axios({ 86 | method: 'GET', 87 | url: url, 88 | headers: { 89 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 90 | }, 91 | ...options 92 | }) 93 | return res.data 94 | } catch (err) { 95 | return err 96 | } 97 | } 98 | 99 | exports.runtime = function(seconds) { 100 | seconds = Number(seconds); 101 | var d = Math.floor(seconds / (3600 * 24)); 102 | var h = Math.floor(seconds % (3600 * 24) / 3600); 103 | var m = Math.floor(seconds % 3600 / 60); 104 | var s = Math.floor(seconds % 60); 105 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 106 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 107 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 108 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 109 | return dDisplay + hDisplay + mDisplay + sDisplay; 110 | } 111 | 112 | exports.clockString = (ms) => { 113 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 114 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 115 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 116 | return [h, m, s].map(v => v.toString().padStart(2, 0)).join(':') 117 | } 118 | 119 | exports.sleep = async (ms) => { 120 | return new Promise(resolve => setTimeout(resolve, ms)); 121 | } 122 | 123 | exports.isUrl = (url) => { 124 | 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')) 125 | } 126 | 127 | exports.getTime = (format, date) => { 128 | if (date) { 129 | return moment(date).locale('id').format(format) 130 | } else { 131 | return moment.tz('Asia/Karachi').locale('id').format(format) 132 | } 133 | } 134 | 135 | exports.formatDate = (n, locale = 'id') => { 136 | let d = new Date(n) 137 | return d.toLocaleDateString(locale, { 138 | weekday: 'long', 139 | day: 'numeric', 140 | month: 'long', 141 | year: 'numeric', 142 | hour: 'numeric', 143 | minute: 'numeric', 144 | second: 'numeric' 145 | }) 146 | } 147 | 148 | exports.tanggal = (numer) => { 149 | myMonths = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]; 150 | myDays = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum’at', 'Sabtu']; 151 | var tgl = new Date(numer); 152 | var day = tgl.getDate() 153 | bulan = tgl.getMonth() 154 | var thisDay = tgl.getDay(), 155 | thisDay = myDays[thisDay]; 156 | var yy = tgl.getYear() 157 | var year = (yy < 1000) ? yy + 1900 : yy; 158 | const time = moment.tz('Asia/Karachi').format('DD/MM HH:mm:ss') 159 | let d = new Date 160 | let locale = 'id' 161 | let gmt = new Date(0).getTime() - new Date('1 January 1970').getTime() 162 | let weton = ['Pahing', 'Pon', 'Wage', 'Kliwon', 'Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5] 163 | 164 | return `${thisDay}, ${day} - ${myMonths[bulan]} - ${year}` 165 | } 166 | exports.jam = (numer, options = {}) => { 167 | let format = options.format ? options.format : "HH:mm" 168 | let jam = options?.timeZone ? moment(numer).tz(timeZone).format(format) : moment(numer).format(format) 169 | 170 | return `${jam}` 171 | } 172 | 173 | exports.formatp = sizeFormatter({ 174 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 175 | decimalPlaces: 2, 176 | keepTrailingZeroes: false, 177 | render: (literal, symbol) => `${literal} ${symbol}B`, 178 | }) 179 | 180 | exports.json = (string) => { 181 | return JSON.stringify(string, null, 2) 182 | } 183 | 184 | function format(...args) { 185 | return util.format(...args) 186 | } 187 | 188 | exports.logic = (check, inp, out) => { 189 | if (inp.length !== out.length) throw new Error('Input and Output must have same length') 190 | for (let i in inp) 191 | if (util.isDeepStrictEqual(check, inp[i])) return out[i] 192 | return null 193 | } 194 | 195 | exports.generateProfilePicture = async (buffer) => { 196 | const jimp = await Jimp.read(buffer) 197 | const min = jimp.getWidth() 198 | const max = jimp.getHeight() 199 | const cropped = jimp.crop(0, 0, min, max) 200 | return { 201 | img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 202 | preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG) 203 | } 204 | } 205 | 206 | exports.bytesToSize = (bytes, decimals = 2) => { 207 | if (bytes === 0) return '0 Bytes'; 208 | 209 | const k = 1024; 210 | const dm = decimals < 0 ? 0 : decimals; 211 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 212 | 213 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 214 | 215 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 216 | } 217 | 218 | exports.getSizeMedia = (path) => { 219 | return new Promise((resolve, reject) => { 220 | if (/http/.test(path)) { 221 | axios.get(path) 222 | .then((res) => { 223 | let length = parseInt(res.headers['content-length']) 224 | let size = exports.bytesToSize(length, 3) 225 | if (!isNaN(length)) resolve(size) 226 | }) 227 | } else if (Buffer.isBuffer(path)) { 228 | let length = Buffer.byteLength(path) 229 | let size = exports.bytesToSize(length, 3) 230 | if (!isNaN(length)) resolve(size) 231 | } else { 232 | reject('error gatau apah') 233 | } 234 | }) 235 | } 236 | 237 | exports.parseMention = (text = '') => { 238 | return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net') 239 | } 240 | 241 | exports.getGroupAdmins = (participants) => { 242 | let admins = [] 243 | for (let i of participants) { 244 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 245 | } 246 | return admins || [] 247 | } 248 | 249 | /** 250 | * Serialize Message 251 | * @param {WAConnection} conn 252 | * @param {Object} m 253 | * @param {store} store 254 | */ 255 | exports.smsg = (XeonBotInc, m, store) => { 256 | if (!m) return m 257 | let M = proto.WebMessageInfo 258 | if (m.key) { 259 | m.id = m.key.id 260 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16 261 | m.chat = m.key.remoteJid 262 | m.fromMe = m.key.fromMe 263 | m.isGroup = m.chat.endsWith('@g.us') 264 | m.sender = XeonBotInc.decodeJid(m.fromMe && XeonBotInc.user.id || m.participant || m.key.participant || m.chat || '') 265 | if (m.isGroup) m.participant = XeonBotInc.decodeJid(m.key.participant) || '' 266 | } 267 | if (m.message) { 268 | m.mtype = getContentType(m.message) 269 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]) 270 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text 271 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null 272 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 273 | if (m.quoted) { 274 | let type = getContentType(quoted) 275 | m.quoted = m.quoted[type] 276 | if (['productMessage'].includes(type)) { 277 | type = getContentType(m.quoted) 278 | m.quoted = m.quoted[type] 279 | } 280 | if (typeof m.quoted === 'string') m.quoted = { 281 | text: m.quoted 282 | } 283 | m.quoted.mtype = type 284 | m.quoted.id = m.msg.contextInfo.stanzaId 285 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat 286 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false 287 | m.quoted.sender = XeonBotInc.decodeJid(m.msg.contextInfo.participant) 288 | m.quoted.fromMe = m.quoted.sender === (XeonBotInc.user && XeonBotInc.user.id) 289 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || '' 290 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 291 | m.getQuotedObj = m.getQuotedMessage = async () => { 292 | if (!m.quoted.id) return false 293 | let q = await store.loadMessage(m.chat, m.quoted.id, XeonBotInc) 294 | return exports.smsg(XeonBotInc, q, store) 295 | } 296 | let vM = m.quoted.fakeObj = M.fromObject({ 297 | key: { 298 | remoteJid: m.quoted.chat, 299 | fromMe: m.quoted.fromMe, 300 | id: m.quoted.id 301 | }, 302 | message: quoted, 303 | ...(m.isGroup ? { 304 | participant: m.quoted.sender 305 | } : {}) 306 | }) 307 | 308 | /** 309 | * 310 | * @returns 311 | */ 312 | m.quoted.delete = () => XeonBotInc.sendMessage(m.quoted.chat, { 313 | delete: vM.key 314 | }) 315 | 316 | /** 317 | * 318 | * @param {*} jid 319 | * @param {*} forceForward 320 | * @param {*} options 321 | * @returns 322 | */ 323 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => XeonBotInc.copyNForward(jid, vM, forceForward, options) 324 | 325 | /** 326 | * 327 | * @returns 328 | */ 329 | m.quoted.download = () => XeonBotInc.downloadMediaMessage(m.quoted) 330 | } 331 | } 332 | if (m.msg.url) m.download = () => XeonBotInc.downloadMediaMessage(m.msg) 333 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || '' 334 | /** 335 | * Reply to this message 336 | * @param {String|Object} text 337 | * @param {String|false} chatId 338 | * @param {Object} options 339 | */ 340 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? XeonBotInc.sendMedia(chatId, text, 'file', '', m, { 341 | ...options 342 | }) : XeonBotInc.sendText(chatId, text, m, { 343 | ...options 344 | }) 345 | /** 346 | * Copy this message 347 | */ 348 | m.copy = () => exports.smsg(XeonBotInc, M.fromObject(M.toObject(m))) 349 | 350 | /** 351 | * 352 | * @param {*} jid 353 | * @param {*} forceForward 354 | * @param {*} options 355 | * @returns 356 | */ 357 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => XeonBotInc.copyNForward(jid, m, forceForward, options) 358 | 359 | return m 360 | } 361 | exports.reSize = (buffer, ukur1, ukur2) => { 362 | return new Promise(async (resolve, reject) => { 363 | var baper = await Jimp.read(buffer); 364 | var ab = await baper.resize(ukur1, ukur2).getBufferAsync(Jimp.MIME_JPEG) 365 | resolve(ab) 366 | }) 367 | } 368 | 369 | let file = require.resolve(__filename) 370 | fs.watchFile(file, () => { 371 | fs.unwatchFile(file) 372 | console.log(chalk.redBright(`Update ${__filename}`)) 373 | delete require.cache[file] 374 | require(file) 375 | }) -------------------------------------------------------------------------------- /allfunc/myfunction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create By king Badboi . 3 | * Contact Me on wa.me/2348140825959 4 | */ 5 | 6 | const { extractMessageContent, jidNormalizedUser, proto, delay, getContentType, areJidsSameUser, generateWAMessage } = require("@whiskeysockets/baileys") 7 | const chalk = require('chalk') 8 | const fs = require('fs') 9 | const Crypto = require('crypto') 10 | const axios = require('axios') 11 | const moment = require('moment-timezone') 12 | const { sizeFormatter } = require('human-readable') 13 | const util = require('util') 14 | const { defaultMaxListeners } = require('stream') 15 | const { read, MIME_JPEG, RESIZE_BILINEAR, AUTO } = require('jimp') 16 | 17 | const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000) 18 | 19 | exports.unixTimestampSeconds = unixTimestampSeconds 20 | 21 | exports.generateMessageTag = (epoch) => { 22 | let tag = (0, exports.unixTimestampSeconds)().toString(); 23 | if (epoch) 24 | tag += '.--' + epoch; // attach epoch if provided 25 | return tag; 26 | } 27 | 28 | exports.processTime = (timestamp, now) => { 29 | return moment.duration(now - moment(timestamp * 1000)).asSeconds() 30 | } 31 | 32 | exports.getRandom = (ext) => { 33 | return `${Math.floor(Math.random() * 10000)}${ext}` 34 | } 35 | 36 | exports.getBuffer = async (url, options) => { 37 | try { 38 | options ? options : {} 39 | const res = await axios({ 40 | method: "get", 41 | url, 42 | headers: { 43 | 'DNT': 1, 44 | 'Upgrade-Insecure-Request': 1 45 | }, 46 | ...options, 47 | responseType: 'arraybuffer' 48 | }) 49 | return res.data 50 | } catch (err) { 51 | return err 52 | } 53 | } 54 | 55 | exports.formatSize = (bytes) => { 56 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; 57 | if (bytes === 0) return '0 Bytes'; 58 | const i = Math.floor(Math.log(bytes) / Math.log(1024)); 59 | return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i]; 60 | }; 61 | 62 | exports.fetchJson = async (url, options) => { 63 | try { 64 | options ? options : {} 65 | const res = await axios({ 66 | method: 'GET', 67 | url: url, 68 | headers: { 69 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 70 | }, 71 | ...options 72 | }) 73 | return res.data 74 | } catch (err) { 75 | return err 76 | } 77 | } 78 | 79 | exports.runtime = function(seconds) { 80 | seconds = Number(seconds); 81 | var d = Math.floor(seconds / (3600 * 24)); 82 | var h = Math.floor(seconds % (3600 * 24) / 3600); 83 | var m = Math.floor(seconds % 3600 / 60); 84 | var s = Math.floor(seconds % 60); 85 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 86 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 87 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 88 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 89 | return dDisplay + hDisplay + mDisplay + sDisplay; 90 | } 91 | 92 | exports.clockString = (ms) => { 93 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 94 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 95 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 96 | return [h, m, s].map(v => v.toString().padStart(2, 0)).join(':') 97 | } 98 | 99 | exports.reSize = async (buffer, x, z) => { 100 | return new Promise(async (resolve, reject) => { 101 | var buff = await read(buffer) 102 | var ab = await buff.resize(x, z).getBufferAsync(MIME_JPEG) 103 | resolve(ab) 104 | }) 105 | } 106 | 107 | exports.sleep = async (ms) => { 108 | return new Promise(resolve => setTimeout(resolve, ms)); 109 | } 110 | 111 | exports.isUrl = (url) => { 112 | 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')) 113 | } 114 | 115 | exports.getTime = (format, date) => { 116 | if (date) { 117 | return moment(date).locale('id').format(format) 118 | } else { 119 | return moment.tz('Asia/Jakarta').locale('id').format(format) 120 | } 121 | } 122 | 123 | exports.formatDate = (n, locale = 'id') => { 124 | let d = new Date(n) 125 | return d.toLocaleDateString(locale, { 126 | weekday: 'long', 127 | day: 'numeric', 128 | month: 'long', 129 | year: 'numeric', 130 | hour: 'numeric', 131 | minute: 'numeric', 132 | second: 'numeric' 133 | }) 134 | } 135 | 136 | exports.tanggal = (numer) => { 137 | myMonths = ["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]; 138 | myDays = ['Minggu','Senin','Selasa','Rabu','Kamis','Jum’at','Sabtu']; 139 | var tgl = new Date(numer); 140 | var day = tgl.getDate() 141 | bulan = tgl.getMonth() 142 | var thisDay = tgl.getDay(), 143 | thisDay = myDays[thisDay]; 144 | var yy = tgl.getYear() 145 | var year = (yy < 1000) ? yy + 1900 : yy; 146 | const time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss') 147 | let d = new Date 148 | let locale = 'id' 149 | let gmt = new Date(0).getTime() - new Date('1 January 1970').getTime() 150 | let weton = ['Pahing', 'Pon','Wage','Kliwon','Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5] 151 | 152 | return`${thisDay}, ${day} - ${myMonths[bulan]} - ${year}` 153 | } 154 | 155 | exports.formatp = sizeFormatter({ 156 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 157 | decimalPlaces: 2, 158 | keepTrailingZeroes: false, 159 | render: (literal, symbol) => `${literal} ${symbol}B`, 160 | }) 161 | 162 | exports.jsonformat = (string) => { 163 | return JSON.stringify(string, null, 2) 164 | } 165 | 166 | function format(...args) { 167 | return util.format(...args) 168 | } 169 | 170 | exports.logic = (check, inp, out) => { 171 | if (inp.length !== out.length) throw new Error('Input and Output must have same length') 172 | for (let i in inp) 173 | if (util.isDeepStrictEqual(check, inp[i])) return out[i] 174 | return null 175 | } 176 | 177 | exports.generateProfilePicture = async (buffer) => { 178 | const jimp = await Jimp.read(buffer) 179 | const min = jimp.getWidth() 180 | const max = jimp.getHeight() 181 | const cropped = jimp.crop(0, 0, min, max) 182 | return { 183 | img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 184 | preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG) 185 | } 186 | } 187 | 188 | exports.sendGmail = async (senderEmail, message) => { 189 | try { 190 | const nodemailer = require("nodemailer") 191 | const transporter = nodemailer.createTransport({ 192 | service: 'gmail', 193 | host: 'smtp.gmail.com', 194 | port: 587, 195 | secure: false, 196 | auth: { 197 | user: "kiuurOTP", 198 | pass: "boqamuoocnticxpm", 199 | }, 200 | }); 201 | 202 | const mailOptions = { 203 | from: "kiuurotp@gmail.com", 204 | to: "client@gmail.com", 205 | subject: 'New Message from ' + senderEmail, 206 | html: message, 207 | }; 208 | 209 | await transporter.sendMail(mailOptions); 210 | console.log('Message sent to your Gmail.'); 211 | } catch (error) { 212 | console.error('Error sending email:', error); 213 | } 214 | } 215 | 216 | exports.bytesToSize = (bytes, decimals = 2) => { 217 | if (bytes === 0) return '0 Bytes'; 218 | 219 | const k = 1024; 220 | const dm = decimals < 0 ? 0 : decimals; 221 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 222 | 223 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 224 | 225 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 226 | } 227 | 228 | exports.getSizeMedia = (path) => { 229 | return new Promise((resolve, reject) => { 230 | if (/http/.test(path)) { 231 | axios.get(path) 232 | .then((res) => { 233 | let length = parseInt(res.headers['content-length']) 234 | let size = exports.bytesToSize(length, 3) 235 | if(!isNaN(length)) resolve(size) 236 | }) 237 | } else if (Buffer.isBuffer(path)) { 238 | let length = Buffer.byteLength(path) 239 | let size = exports.bytesToSize(length, 3) 240 | if(!isNaN(length)) resolve(size) 241 | } else { 242 | reject('error gatau apah') 243 | } 244 | }) 245 | } 246 | 247 | exports.parseMention = (text = '') => { 248 | return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net') 249 | } 250 | 251 | exports.getGroupAdmins = (participants) => { 252 | let admins = [] 253 | for (let i of participants) { 254 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 255 | } 256 | return admins || [] 257 | } 258 | 259 | /** 260 | * Serialize Message 261 | * @param {WAConnection} conn 262 | * @param {Object} m 263 | * @param {store} store 264 | */ 265 | exports.smsg = (client, m, store) => { 266 | if (!m) return m 267 | let M = proto.WebMessageInfo 268 | if (m.key) { 269 | m.id = m.key.id 270 | m.from = m.key.remoteJid.startsWith('status') ? jidNormalizedUser(m.key?.participant || m.participant) : jidNormalizedUser(m.key.remoteJid); 271 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16 272 | m.chat = m.key.remoteJid 273 | m.fromMe = m.key.fromMe 274 | m.isGroup = m.chat.endsWith('@g.us') 275 | m.sender = client.decodeJid(m.fromMe && client.user.id || m.participant || m.key.participant || m.chat || '') 276 | if (m.isGroup) m.participant = client.decodeJid(m.key.participant) || '' 277 | } 278 | if (m.message) { 279 | m.mtype = getContentType(m.message) 280 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]) 281 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text 282 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null 283 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 284 | if (m.quoted) { 285 | let type = getContentType(quoted) 286 | m.quoted = m.quoted[type] 287 | if (['productMessage'].includes(type)) { 288 | type = getContentType(m.quoted) 289 | m.quoted = m.quoted[type] 290 | } 291 | if (typeof m.quoted === 'string') m.quoted = { 292 | text: m.quoted 293 | } 294 | 295 | m.quoted.key = { 296 | remoteJid: m.msg?.contextInfo?.remoteJid || m.from, 297 | participant: jidNormalizedUser(m.msg?.contextInfo?.participant), 298 | fromMe: areJidsSameUser(jidNormalizedUser(m.msg?.contextInfo?.participant), jidNormalizedUser(client?.user?.id)), 299 | id: m.msg?.contextInfo?.stanzaId, 300 | }; 301 | 302 | m.quoted.mtype = type 303 | m.quoted.from = /g\.us|status/.test(m.msg?.contextInfo?.remoteJid) ? m.quoted.key.participant : m.quoted.key.remoteJid; 304 | m.quoted.id = m.msg.contextInfo.stanzaId 305 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat 306 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false 307 | m.quoted.sender = client.decodeJid(m.msg.contextInfo.participant) 308 | m.quoted.fromMe = m.quoted.sender === (client.user && client.user.id) 309 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || '' 310 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : [] 311 | m.getQuotedObj = m.getQuotedMessage = async () => { 312 | if (!m.quoted.id) return false 313 | let q = await store.loadMessage(m.chat, m.quoted.id, client) 314 | return exports.smsg(client, q, store) 315 | } 316 | let vM = m.quoted.fakeObj = M.fromObject({ 317 | key: { 318 | remoteJid: m.quoted.chat, 319 | fromMe: m.quoted.fromMe, 320 | id: m.quoted.id 321 | }, 322 | message: quoted, 323 | ...(m.isGroup ? { participant: m.quoted.sender } : {}) 324 | }) 325 | 326 | /** 327 | * 328 | * @returns 329 | */ 330 | m.quoted.delete = () => client.sendMessage(m.quoted.chat, { delete: vM.key }) 331 | 332 | /** 333 | * 334 | * @param {*} jid 335 | * @param {*} forceForward 336 | * @param {*} options 337 | * @returns 338 | */ 339 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => client.copyNForward(jid, vM, forceForward, options) 340 | 341 | /** 342 | * 343 | * @returns 344 | */ 345 | m.quoted.download = () => client.downloadMediaMessage(m.quoted) 346 | } 347 | } 348 | if (m.msg.url) m.download = () => client.downloadMediaMessage(m.msg) 349 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || '' 350 | /** 351 | * Reply to this message 352 | * @param {String|Object} text 353 | * @param {String|false} chatId 354 | * @param {Object} options 355 | */ 356 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? client.sendMedia(chatId, text, 'file', '', m, { ...options }) : client.sendText(chatId, text, m, { ...options }) 357 | /** 358 | * Copy this message 359 | */ 360 | m.copy = () => exports.smsg(client, M.fromObject(M.toObject(m))) 361 | 362 | /** 363 | * 364 | * @param {*} jid 365 | * @param {*} forceForward 366 | * @param {*} options 367 | * @returns 368 | */ 369 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => client.copyNForward(jid, m, forceForward, options) 370 | 371 | return m 372 | } 373 | 374 | 375 | let file = require.resolve(__filename) 376 | fs.watchFile(file, () => { 377 | fs.unwatchFile(file) 378 | console.log(chalk.redBright(`Update ${__filename}`)) 379 | delete require.cache[file] 380 | require(file) 381 | }) 382 | -------------------------------------------------------------------------------- /allfunc/myfunc3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create By king Badboi . 3 | * Contact Me on wa.me/2348140825959 4 | */ 5 | 6 | 7 | const { proto, delay, getContentType } = require('@whiskeysockets/baileys') 8 | const chalk = require('chalk') 9 | const axios = require('axios'); 10 | const { sizeFormatter } = require('human-readable'); 11 | const fs = require("fs"); 12 | const Jimp = require("jimp"); 13 | 14 | // exports serialize 15 | exports.serialize = (ptz, m) => { 16 | m.isGroup = m.key.remoteJid.endsWith('@g.us') 17 | try{ 18 | const berak = Object.keys(m.message)[0] 19 | m.type = berak 20 | } catch { 21 | m.type = null 22 | } 23 | try{ 24 | const context = m.message[m.type].contextInfo.quotedMessage 25 | if(context["ephemeralMessage"]){ 26 | m.quotedMsg = context.ephemeralMessage.message 27 | }else{ 28 | m.quotedMsg = context 29 | } 30 | m.isQuotedMsg = true 31 | m.quotedMsg.sender = m.message[m.type].contextInfo.participant 32 | m.quotedMsg.fromMe = m.quotedMsg.sender === ramz.user.id.split(':')[0]+'@s.whatsapp.net' ? true : false 33 | m.quotedMsg.type = Object.keys(m.quotedMsg)[0] 34 | let ane = m.quotedMsg 35 | m.quotedMsg.chats = (ane.type === 'conversation' && ane.conversation) ? ane.conversation : (ane.type == 'imageMessage') && ane.imageMessage.caption ? ane.imageMessage.caption : (ane.type == 'documentMessage') && ane.documentMessage.caption ? ane.documentMessage.caption : (ane.type == 'videoMessage') && ane.videoMessage.caption ? ane.videoMessage.caption : (ane.type == 'extendedTextMessage') && ane.extendedTextMessage.text ? ane.extendedTextMessage.text : (ane.type == 'buttonsMessage') && ane.buttonsMessage.contentText ? ane.buttonsMessage.contentText : "" 36 | m.quotedMsg.id = m.message[m.type].contextInfo.stanzaId 37 | }catch{ 38 | m.quotedMsg = null 39 | m.isQuotedMsg = false 40 | } 41 | 42 | try{ 43 | const mention = m.message[m.type].contextInfo.mentionedJid 44 | m.mentioned = mention 45 | }catch{ 46 | m.mentioned = [] 47 | } 48 | 49 | if (m.isGroup){ 50 | m.sender = m.participant 51 | }else{ 52 | m.sender = m.key.remoteJid 53 | } 54 | if (m.key.fromMe){ 55 | m.sender = ptz.user.id.split(':')[0]+'@s.whatsapp.net' 56 | } 57 | 58 | m.from = m.key.remoteJid 59 | m.now = m.messageTimestamp 60 | m.fromMe = m.key.fromMe 61 | 62 | return m 63 | } 64 | 65 | exports.randomInt = (min, max) => { 66 | min = Math.ceil(min) 67 | max = Math.floor(max) 68 | return Math.floor(Math.random() * (max - min + 1)) + min 69 | } 70 | 71 | exports.color = (text, color) => { 72 | return !color ? chalk.green(text) : chalk.keyword(color)(text) 73 | 74 | } 75 | exports.getGroupAdmins = (participants) => { 76 | let admins = [] 77 | for (let i of participants) { 78 | i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : '' 79 | } 80 | return admins || [] 81 | } 82 | 83 | exports.generateProfilePicture = async (buffer) => { 84 | const jimp = await Jimp.read(buffer); 85 | const min = jimp.getWidth(); 86 | const max = jimp.getHeight(); 87 | const cropped = jimp.crop(0, 0, min, max); 88 | return { 89 | img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 90 | preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG), 91 | }; 92 | }; 93 | 94 | exports.getBuffer = async (url, options) => { 95 | try { 96 | options ? options : {} 97 | const res = await axios({ 98 | method: "get", 99 | url, 100 | headers: { 101 | 'DNT': 1, 102 | 'Upgrade-Insecure-Request': 1 103 | }, 104 | ...options, 105 | responseType: 'arraybuffer' 106 | }) 107 | return res.data 108 | } catch (err) { 109 | return err 110 | } 111 | } 112 | 113 | 114 | exports.toRupiah = function(x){ 115 | x = x.toString() 116 | var pattern = /(-?\d+)(\d{3})/ 117 | while (pattern.test(x)) 118 | x = x.replace(pattern, "$1.$2") 119 | return x 120 | } 121 | 122 | exports.sleep = async (ms) => { 123 | return new Promise(resolve => setTimeout(resolve, ms)); 124 | } 125 | 126 | exports.parseMention = (text = '') => { 127 | return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net') 128 | } 129 | 130 | exports.bytesToSize = (bytes, decimals = 2) => { 131 | if (bytes === 0) return '0 Bytes'; 132 | const k = 1024; 133 | const dm = decimals < 0 ? 0 : decimals; 134 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 135 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 136 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; 137 | }; 138 | 139 | exports.msToDate = (ms) => { 140 | let years = Math.floor(ms / (1000 * 60 * 60 * 24 * 365)); 141 | let months = Math.floor( 142 | (ms % (1000 * 60 * 60 * 24 * 365)) / (1000 * 60 * 60 * 24 * 30) 143 | ); 144 | let weeks = Math.floor( 145 | (ms % (1000 * 60 * 60 * 24 * 30)) / (1000 * 60 * 60 * 24 * 7) 146 | ); 147 | let days = Math.floor( 148 | (ms % (1000 * 60 * 60 * 24 * 7)) / (1000 * 60 * 60 * 24) 149 | ); 150 | return `${years} tahun ${months} bulan ${weeks} minggu ${days} hari`; 151 | }; 152 | 153 | exports.msToDay = (ms) => { 154 | let temp = ms; 155 | let years = Math.floor(temp / (365 * 24 * 60 * 60 * 1000)); 156 | temp = temp % (365 * 24 * 60 * 60 * 1000); 157 | let months = Math.floor(temp / (30 * 24 * 60 * 60 * 1000)); 158 | temp = temp % (30 * 24 * 60 * 60 * 1000); 159 | let weeks = Math.floor(temp / (7 * 24 * 60 * 60 * 1000)); 160 | temp = temp % (7 * 24 * 60 * 60 * 1000); 161 | let days = Math.floor(temp / (24 * 60 * 60 * 1000)); 162 | temp = temp % (24 * 60 * 60 * 1000); 163 | let hours = Math.floor(temp / (60 * 60 * 1000)); 164 | temp = temp % (60 * 60 * 1000); 165 | let minutes = Math.floor(temp / (60 * 1000)); 166 | temp = temp % (60 * 1000); 167 | 168 | let result = ""; 169 | if (years > 0) { 170 | result += years + (years > 1 ? " tahun " : " tahun "); 171 | } 172 | if (months > 0) { 173 | result += months + (months > 1 ? " bulan " : " bulan "); 174 | } 175 | if (weeks > 0) { 176 | result += weeks + (weeks > 1 ? " minggu " : " minggu "); 177 | } 178 | if (days > 0) { 179 | result += days + (days > 1 ? " hari " : " hari "); 180 | } 181 | if (hours > 0) { 182 | result += hours + (hours > 1 ? " jam " : " jam "); 183 | } 184 | if (minutes > 0) { 185 | result += minutes + (minutes > 1 ? " menit " : " menit "); 186 | } 187 | return result.trim(); 188 | }; 189 | 190 | exports.checkBandwidth = async () => { 191 | let ind = 0; 192 | let out = 0; 193 | for (let i of await require("node-os-utils").netstat.stats()) { 194 | ind += parseInt(i.inputBytes); 195 | out += parseInt(i.outputBytes); 196 | } 197 | return { 198 | download: exports.bytesToSize(ind), 199 | upload: exports.bytesToSize(out), 200 | }; 201 | }; 202 | 203 | exports.formatSize = (bytes) => { 204 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; 205 | if (bytes === 0) return '0 Bytes'; 206 | const i = Math.floor(Math.log(bytes) / Math.log(1024)); 207 | return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i]; 208 | }; 209 | 210 | exports.getRandom = (ext) => { 211 | return `${Math.floor(Math.random() * 10000)}${ext}`; 212 | }; 213 | 214 | exports.getBuffer = async (url, options) => { 215 | try { 216 | options = options || {}; 217 | const res = await axios({ 218 | method: "get", 219 | url, 220 | headers: { 221 | 'DNT': 1, 222 | 'Upgrade-Insecure-Request': 1 223 | }, 224 | ...options, 225 | responseType: 'arraybuffer' 226 | }); 227 | return res.data; 228 | } catch (err) { 229 | return err; 230 | } 231 | }; 232 | 233 | exports.isUrl = (url) => { 234 | 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')); 235 | }; 236 | 237 | exports.jsonformat = (string) => { 238 | return JSON.stringify(string, null, 2); 239 | }; 240 | 241 | exports.nganuin = async (url, options) => { 242 | try { 243 | options = options || {}; 244 | const res = await axios({ 245 | method: 'GET', 246 | url: url, 247 | headers: { 248 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 249 | }, 250 | ...options 251 | }); 252 | return res.data; 253 | } catch (err) { 254 | return err; 255 | } 256 | }; 257 | 258 | exports.pickRandom = (ext) => { 259 | return `${Math.floor(Math.random() * 10000)}${ext}`; 260 | }; 261 | 262 | exports.runtime = function (seconds) { 263 | seconds = Number(seconds); 264 | var d = Math.floor(seconds / (3600 * 24)); 265 | var h = Math.floor(seconds % (3600 * 24) / 3600); 266 | var m = Math.floor(seconds % 3600 / 60); 267 | var s = Math.floor(seconds % 60); 268 | var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; 269 | var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; 270 | var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; 271 | var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; 272 | return dDisplay + hDisplay + mDisplay + sDisplay; 273 | }; 274 | 275 | exports.shorturl = async function shorturl(longUrl) { 276 | try { 277 | const data = { url: longUrl }; 278 | const response = await axios.post('https://shrtrl.vercel.app/', data); 279 | return response.data.data.shortUrl; 280 | } catch (error) { 281 | return error; 282 | } 283 | }; 284 | 285 | exports.msToTime = (ms) => { 286 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 287 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 288 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 289 | return [h + ' Jam ', m + ' Menit ', s + ' Detik'].map(v => v.toString().padStart(2, 0)).join(' ') 290 | } 291 | 292 | exports.msToHour = (ms) => { 293 | let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000) 294 | return [h + ' Jam '].map(v => v.toString().padStart(2, 0)).join(' ') 295 | } 296 | 297 | exports.msToMinute = (ms) => { 298 | let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60 299 | return [m + ' Menit '].map(v => v.toString().padStart(2, 0)).join(' ') 300 | } 301 | 302 | exports.msToSecond = (ms) => { 303 | let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60 304 | return [s + ' Detik'].map(v => v.toString().padStart(2, 0)).join(' ') 305 | } 306 | 307 | 308 | exports.fetchJson = async (url, options) => { 309 | try { 310 | options ? options : {} 311 | const res = await axios({ 312 | method: 'GET', 313 | url: url, 314 | headers: { 315 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' 316 | }, 317 | ...options 318 | }) 319 | return res.data 320 | } catch (err) { 321 | return err 322 | } 323 | } 324 | exports.clockString = (ms) => { 325 | let h = Math.floor(ms / 3600000) 326 | let m = Math.floor(ms / 60000) % 60 327 | let s = Math.floor(ms / 1000) % 60 328 | console.log({ms,h,m,s}) 329 | return [h, m, s].map(v => v.toString().padStart(2, 0) ).join(':') 330 | } 331 | 332 | exports.formatp = sizeFormatter({ 333 | std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC' 334 | decimalPlaces: 2, 335 | keepTrailingZeroes: false, 336 | render: (literal, symbol) => `${literal} ${symbol}B` 337 | }); 338 | 339 | exports.smsg = (ptz, m, store) => { 340 | try { 341 | if (!m) return m; 342 | let M = proto.WebMessageInfo; 343 | if (m.key) { 344 | m.id = m.key.id; 345 | m.isBaileys = m.id.startsWith('BAE5') && m.id.length === 16; 346 | m.chat = m.key.remoteJid; 347 | m.fromMe = m.key.fromMe; 348 | m.isGroup = m.chat.endsWith('@g.us'); 349 | m.sender = ptz.decodeJid(m.fromMe && ptz.user.id || m.participant || m.key.participant || m.chat || ''); 350 | if (m.isGroup) m.participant = ptz.decodeJid(m.key.participant) || ''; 351 | } 352 | if (m.message) { 353 | m.mtype = getContentType(m.message); 354 | m.msg = (m.mtype == 'viewOnceMessage' ? m.message[m.mtype].message[getContentType(m.message[m.mtype].message)] : m.message[m.mtype]); 355 | m.body = m.message.conversation || m.msg.caption || m.msg.text || (m.mtype == 'listResponseMessage') && m.msg.singleSelectReply.selectedRowId || (m.mtype == 'buttonsResponseMessage') && m.msg.selectedButtonId || (m.mtype == 'viewOnceMessage') && m.msg.caption || m.text; 356 | let quoted = m.quoted = m.msg.contextInfo ? m.msg.contextInfo.quotedMessage : null; 357 | m.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : []; 358 | if (m.msg.caption) { 359 | m.caption = m.msg.caption; 360 | } 361 | if (m.quoted) { 362 | let type = Object.keys(m.quoted)[0]; 363 | m.quoted = m.quoted[type]; 364 | if (['productMessage'].includes(type)) { 365 | type = Object.keys(m.quoted)[0]; 366 | m.quoted = m.quoted[type]; 367 | } 368 | if (typeof m.quoted === 'string') m.quoted = { 369 | text: m.quoted 370 | }; 371 | m.quoted.mtype = type; 372 | m.quoted.id = m.msg.contextInfo.stanzaId; 373 | m.quoted.chat = m.msg.contextInfo.remoteJid || m.chat; 374 | m.quoted.isBaileys = m.quoted.id ? m.quoted.id.startsWith('BAE5') && m.quoted.id.length === 16 : false; 375 | m.quoted.sender = ptz.decodeJid(m.msg.contextInfo.participant); 376 | m.quoted.fromMe = m.quoted.sender === ptz.decodeJid(ptz.user.id); 377 | m.quoted.text = m.quoted.text || m.quoted.caption || m.quoted.conversation || m.quoted.contentText || m.quoted.selectedDisplayText || m.quoted.title || ''; 378 | m.quoted.mentionedJid = m.msg.contextInfo ? m.msg.contextInfo.mentionedJid : []; 379 | m.getQuotedObj = m.getQuotedMessage = async () => { 380 | if (!m.quoted.id) return false; 381 | let q = await store.loadMessage(m.chat, m.quoted.id, ptz); 382 | return smsg(ptz, q, store); 383 | }; 384 | let vM = m.quoted.fakeObj = M.fromObject({ 385 | key: { 386 | remoteJid: m.quoted.chat, 387 | fromMe: m.quoted.fromMe, 388 | id: m.quoted.id 389 | }, 390 | message: quoted, 391 | ...(m.isGroup ? { participant: m.quoted.sender } : {}) 392 | }); 393 | m.quoted.delete = () => ptz.sendMessage(m.quoted.chat, { delete: vM.key }); 394 | m.quoted.copyNForward = (jid, forceForward = false, options = {}) => ptz.copyNForward(jid, vM, forceForward, options); 395 | m.quoted.download = () => ptz.downloadMediaMessage(m.quoted); 396 | } 397 | } 398 | if (m.msg.url) m.download = () => ptz.downloadMediaMessage(m.msg); 399 | m.text = m.msg.text || m.msg.caption || m.message.conversation || m.msg.contentText || m.msg.selectedDisplayText || m.msg.title || ''; 400 | m.reply = (text, chatId = m.chat, options = {}) => Buffer.isBuffer(text) ? ptz.sendMedia(chatId, text, 'file', '', m, { ...options }) : ptz.sendText(chatId, text, m, { ...options }); 401 | m.copy = () => smsg(ptz, M.fromObject(M.toObject(m))); 402 | m.copyNForward = (jid = m.chat, forceForward = false, options = {}) => ptz.copyNForward(jid, m, forceForward, options); 403 | ptz.appenTextMessage = async(text, chatUpdate) => { 404 | let messages = await generateWAMessage(m.chat, { text: text, mentions: m.mentionedJid }, { 405 | userJid: ptz.user.id, 406 | quoted: m.quoted && m.quoted.fakeObj 407 | }); 408 | messages.key.fromMe = areJidsSameUser(m.sender, ptz.user.id); 409 | messages.key.id = m.key.id; 410 | messages.pushName = m.pushName; 411 | if (m.isGroup) messages.participant = m.sender; 412 | let msg = { 413 | ...chatUpdate, 414 | messages: [proto.WebMessageInfo.fromObject(messages)], 415 | type: 'append' 416 | }; 417 | ptz.ev.emit('messages.upsert', msg); 418 | }; 419 | 420 | return m; 421 | } catch (e) { 422 | 423 | } 424 | }; 425 | 426 | let file = require.resolve(__filename) 427 | fs.watchFile(file, () => { 428 | fs.unwatchFile(file) 429 | console.log(chalk.redBright(`Update ${__filename}`)) 430 | delete require.cache[file] 431 | require(file) 432 | }) 433 | --------------------------------------------------------------------------------