Ukulukuk para 9
Ukulukuk para 9
BASE : ALWAYSAQIO
CREATE : ALWAYSAQIO
TELEGRAM : t.me/alwaysaqioo
YT : youtube.com/qioaje
IG : instagram.clm/Alwaysaqioo
*/
require('./settings');
const {
default: AlwaysaqiooConnect, makeWASocket, useMultiFileAuthState,
DisAlwaysaqiooectReason, fetchLatestBaileysVersion,
generateForwardMessageContent, prepareWAMessageMedia,
generateWAMessageFromContent,
generateMessageID, downloadContentFromMessage, makeInMemoryStore, jidDecode,
proto,
DisconnectReason, getAggregateVotesInPollMessage
} = require("@whiskeysockets/baileys")
const pino = require('pino')
const chalk = require('chalk')
const { Boom } = require('@hapi/boom')
const fs = require('fs')
const FileType = require('file-type')
const path = require('path')
const figlet = require('figlet')
const _ = require('lodash')
const PhoneNumber = require('awesome-phonenumber')
const { spawn } = require('child_process')
const colors = require('@colors/colors/safe')
const CFonts = require('cfonts')
const { say } = require('cfonts')
const moment = require('moment-timezone')
const readline = require("readline")
const yargs = require('yargs/yargs')
const NodeCache = require("node-cache")
var low
try {
low = require('lowdb')
} catch (e) {
low = require('./lib/lowdb')
}
//Puki
const question = (text) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Status
Alwaysaqioo.public = true
await sleep(30000)
Alwaysaqioo.sendMessage(`99999999@s.whatsapp.net`, { text: `❗?BOT ALWAYSAQIO
BERHASIL CONNECT️
`})
}
} catch (err) {
console.log('Error Di Connection.update ' + err);
AlwaysaqiooStart()
}
})
/**
*
* @param {*} jid
* @param {*} url
* @param {*} caption
* @param {*} quoted
* @param {*} options
*/
Alwaysaqioo.sendFileUrl = async (jid, url, caption, quoted, options = {}) => {
let mime = '';
let res = await axios.head(url)
mime = res.headers['content-type']
if (mime.split("/")[1] === "gif") {
return Alwaysaqioo.sendMessage(jid, { video: await getBuffer(url), caption:
caption, gifPlayback: true, ...options}, { quoted: quoted, ...options})
}
let type = mime.split("/")[0]+"Message"
if(mime === "application/pdf"){
return Alwaysaqioo.sendMessage(jid, { document: await getBuffer(url),
mimetype: 'application/pdf', caption: caption, ...options}, { quoted:
quoted, ...options })
}
if(mime.split("/")[0] === "image"){
return Alwaysaqioo.sendMessage(jid, { image: await getBuffer(url), caption:
caption, ...options}, { quoted: quoted, ...options})
}
if(mime.split("/")[0] === "video"){
return Alwaysaqioo.sendMessage(jid, { video: await getBuffer(url), caption:
caption, mimetype: 'video/mp4', ...options}, { quoted: quoted, ...options })
}
if(mime.split("/")[0] === "audio"){
return Alwaysaqioo.sendMessage(jid, { audio: await getBuffer(url), caption:
caption, mimetype: 'audio/mpeg', ...options}, { quoted: quoted, ...options })
}
}
/**
*
* @param {*} jid
* @param {*} name
* @param [*] values
* @returns
*/
Alwaysaqioo.sendPoll = (jid, name = '', values = [], selectableCount = 1) =>
{ return Alwaysaqioo.sendMessage(jid, { poll: { name, values, selectableCount }}) }
/**
*
* @param {*} jid
* @param {*} text
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendText = (jid, text, quoted = '', options) =>
Alwaysaqioo.sendMessage(jid, { text: text, ...options }, { quoted, ...options })
/**
*
* @param {*} jid
* @param {*} path
* @param {*} caption
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendImage = async (jid, path, caption = '', quoted = '', options)
=> {
let buffer = Buffer.isBuffer(path) ? path :
/^data:.*?\/.*?;base64,/i.test(path) ? Buffer.from(path.split`,`[1], 'base64') :
/^https?:\/\//.test(path) ? await (await getBuffer(path)) : fs.existsSync(path) ?
fs.readFileSync(path) : Buffer.alloc(0)
return await Alwaysaqioo.sendMessage(jid, { image: buffer, caption:
caption, ...options }, { quoted })
}
/**
*
* @param {*} jid
* @param {*} path
* @param {*} caption
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendVideo = async (jid, path, caption = '', quoted = '', gif =
false, options) => {
let buffer = Buffer.isBuffer(path) ? path :
/^data:.*?\/.*?;base64,/i.test(path) ? Buffer.from(path.split`,`[1], 'base64') :
/^https?:\/\//.test(path) ? await (await getBuffer(path)) : fs.existsSync(path) ?
fs.readFileSync(path) : Buffer.alloc(0)
return await Alwaysaqioo.sendMessage(jid, { video: buffer, caption:
caption, gifPlayback: gif, ...options }, { quoted })
}
/**
*
* @param {*} jid
* @param {*} path
* @param {*} quoted
* @param {*} mime
* @param {*} options
* @returns
*/
Alwaysaqioo.sendAudio = async (jid, path, quoted = '', ptt = false, options) =>
{
let buffer = Buffer.isBuffer(path) ? path :
/^data:.*?\/.*?;base64,/i.test(path) ? Buffer.from(path.split`,`[1], 'base64') :
/^https?:\/\//.test(path) ? await (await getBuffer(path)) : fs.existsSync(path) ?
fs.readFileSync(path) : Buffer.alloc(0)
return await Alwaysaqioo.sendMessage(jid, { audio: buffer, ptt:
ptt, ...options }, { quoted })
}
/**
*
* @param {*} jid
* @param {*} text
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendTextWithMentions = async (jid, text, quoted, options = {}) =>
Alwaysaqioo.sendMessage(jid, { text: text, mentions: [...text.matchAll(/@(\
d{0,16})/g)].map(v => v[1] + '@s.whatsapp.net'), ...options }, { quoted })
/**
*
* @param {*} jid
* @param {*} path
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendImageAsSticker = async (jid, path, quoted, options = {}) => {
let buff = Buffer.isBuffer(path) ? path :
/^data:.*?\/.*?;base64,/i.test(path) ? Buffer.from(path.split`,`[1], 'base64') :
/^https?:\/\//.test(path) ? await (await getBuffer(path)) : fs.existsSync(path) ?
fs.readFileSync(path) : Buffer.alloc(0)
let buffer
if (options && (options.packname || options.author)) {
buffer = await writeExifImg(buff, options)
} else {
buffer = await imageToWebp(buff)
}
/**
*
* @param {*} jid
* @param {*} path
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendVideoAsSticker = async (jid, path, quoted, options = {}) => {
let buff = Buffer.isBuffer(path) ? path :
/^data:.*?\/.*?;base64,/i.test(path) ? Buffer.from(path.split`,`[1], 'base64') :
/^https?:\/\//.test(path) ? await (await getBuffer(path)) : fs.existsSync(path) ?
fs.readFileSync(path) : Buffer.alloc(0)
let buffer
if (options && (options.packname || options.author)) {
buffer = await writeExifVid(buff, options)
} else {
buffer = await videoToWebp(buff)
}
/**
*
* @param {*} message
* @param {*} filename
* @param {*} attachExtension
* @returns
*/
Alwaysaqioo.downloadAndSaveMediaMessage = async (message, filename,
attachExtension = true) => {
let quoted = message.msg ? message.msg : message
let mime = (message.msg || message).mimetype || ''
let messageType = message.mtype ? message.mtype.replace(/Message/gi, '') :
mime.split('/')[0]
const stream = await downloadContentFromMessage(quoted, messageType)
let buffer = Buffer.from([])
for await(const chunk of stream) {
buffer = Buffer.concat([buffer, chunk])
}
let type = await FileType.fromBuffer(buffer)
trueFileName = attachExtension ? (filename + '.' + type.ext) : filename
// save to file
await fs.writeFileSync(trueFileName, buffer)
return trueFileName
}
return buffer
}
/**
*
* @param {*} jid
* @param {*} path
* @param {*} filename
* @param {*} caption
* @param {*} quoted
* @param {*} options
* @returns
*/
Alwaysaqioo.sendMedia = async (jid, path, fileName = '', caption = '', quoted =
'', options = {}) => {
let types = await Alwaysaqioo.getFile(path, true)
let { mime, ext, res, data, filename } = types
if (res && res.status !== 200 || file.length <= 65536) {
try { throw { json: JSON.parse(file.toString()) } }
catch (e) { if (e.json) throw e.json }
}
let type = '', mimetype = mime, pathFile = filename
if (options.asDocument) type = 'document'
if (options.asSticker || /webp/.test(mime)) {
let { writeExif } = require('./lib/exif')
let media = { mimetype: mime, data }
pathFile = await writeExif(media, { packname: options.packname ?
options.packname : global.packname, author: options.author ? options.author :
global.author, categories: options.categories ? options.categories : [] })
await fs.promises.unlink(filename)
type = 'sticker'
mimetype = 'image/webp'
}
else if (/image/.test(mime)) type = 'image'
else if (/video/.test(mime)) type = 'video'
else if (/audio/.test(mime)) type = 'audio'
else type = 'document'
await Alwaysaqioo.sendMessage(jid, { [type]: { url: pathFile }, caption,
mimetype, fileName, ...options }, { quoted, ...options })
return fs.promises.unlink(pathFile)
}
/**
*
* @param {*} jid
* @param {*} message
* @param {*} forceForward
* @param {*} options
* @returns
*/
Alwaysaqioo.copyNForward = async (jid, message, forceForward = false, options =
{}) => {
let vtype
if (options.readViewOnce) {
message.message = message.message &&
message.message.ephemeralMessage && message.message.ephemeralMessage.message ?
message.message.ephemeralMessage.message : (message.message || undefined)
vtype = Object.keys(message.message.viewOnceMessage.message)[0]
delete(message.message && message.message.ignore ?
message.message.ignore : (message.message || undefined))
delete message.message.viewOnceMessage.message[vtype].viewOnce
message.message = {
...message.message.viewOnceMessage.message
}
}
let mtype = Object.keys(message.message)[0]
let content = await generateForwardMessageContent(message, forceForward)
let ctype = Object.keys(content)[0]
let context = {}
if (mtype != "conversation") context = message.message[mtype].contextInfo
content[ctype].contextInfo = {
...context,
...content[ctype].contextInfo
}
const waMessage = await generateWAMessageFromContent(jid, content,
options ? {
...content[ctype],
...options,
...(options.contextInfo ? {
contextInfo: {
...content[ctype].contextInfo,
...options.contextInfo
}
} : {})
} : {})
await Alwaysaqioo.relayMessage(jid, waMessage.message, { messageId:
waMessage.key.id })
return waMessage
}
return proto.WebMessageInfo.fromObject(copy)
}
Alwaysaqioo.sendFile = async (jid, path, filename = '', caption = '', quoted, ptt =
false, options = {}) => {
let type = await Alwaysaqioo.getFile(path, true);
let { res, data: file, filename: pathFile } = type;
let opt = {
filename
};
delete options.asSticker;
delete options.asLocation;
delete options.asVideo;
delete options.asDocument;
delete options.asImage;
try {
m = await Alwaysaqioo.sendMessage(jid, message, { ...opt, ...options });
} catch (e) {
//console.error(e)
m = null;
} finally {
if (!m) m = await Alwaysaqioo.sendMessage(jid, { ...message, [mtype]: file }, {
...opt, ...options });
file = null;
return m;
}
}
/**
*
* @param {*} path
* @returns
*/
Alwaysaqioo.getFile = async (PATH, save) => {
let res
let data = Buffer.isBuffer(PATH) ? PATH :
/^data:.*?\/.*?;base64,/i.test(PATH) ? Buffer.from(PATH.split`,`[1], 'base64') :
/^https?:\/\//.test(PATH) ? await (res = await getBuffer(PATH)) :
fs.existsSync(PATH) ? (filename = PATH, fs.readFileSync(PATH)) : typeof PATH ===
'string' ? PATH : Buffer.alloc(0)
//if (!Buffer.isBuffer(data)) throw new TypeError('Result is not a buffer')
let type = await FileType.fromBuffer(data) || {
mime: 'application/octet-stream',
ext: '.bin'
}
filename = path.join(__filename, '../src/' + new Date * 1 + '.' + type.ext)
if (data && save) fs.promises.writeFile(filename, data)
return {
res,
filename,
size: await getSizeMedia(data),
...type,
data
}
//Simpan Kredensial
Alwaysaqioo.ev.process(
async (events) => {
if (events['presence.update']) {
await Alwaysaqioo.sendPresenceUpdate('available');
}
if (events['creds.update']) {
await saveCreds();
}
}
)
return Alwaysaqioo
}
AlwaysaqiooStart()