zaileys 1.1.40-tx.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +286 -9
- package/dist/index.d.mts +90 -6
- package/dist/index.d.ts +90 -6
- package/dist/index.js +15 -15
- package/dist/index.mjs +15 -15
- package/package.json +63 -63
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import Gt,{URL_REGEX,extractMessageContent,getContentType,BufferJSON,initAuthCreds,proto,makeCacheableSignalKeyStore,isJidBroadcast,generateWAMessageFromContent,generateMessageIDV2,isJidGroup,delay,DisconnectReason,jidNormalizedUser,getDevice,downloadMediaMessage}from'baileys';import Pe,{readFile,mkdir,writeFile,unlink,readdir,rmdir,stat}from'fs/promises';import {Mutex}from'async-mutex';import*as Le from'path';import Le__default,{dirname,join}from'path';import {createSpinner}from'nanospinner';import $e from'node-cache';import {EventEmitter}from'events';import Ct from'pino';import Ge,{cristal}from'gradient-string';import b,{isBuffer,isArrayBuffer,isString}from'lodash';import {fileTypeFromBuffer}from'file-type';import H from'fluent-ffmpeg';import Bt from'node-webpmux';import {tmpdir}from'os';import Re from'sharp';import Zt from'figlet';import Yt from'qrcode-terminal';import {RateLimiterMemory}from'rate-limiter-flexible';import u,{z}from'zod';import*as be from'fs';import {pathToFileURL}from'url';var qe=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Ie=class{data=new Map;cache=new Map;set(e,t){this.data.set(e,{...this.data.get(e),...t});}get(e){return this.data.get(e)||{}}update(e,t){let i=this.get(e);this.set(e,t(i));}delete(e){this.data.delete(e);}has(e){return this.data.has(e)}lowdb(e,t){let i=`.session/${e}/${t}`;if(this.cache.has(i))return this.cache.get(i);let n=q(i);return this.cache.set(i,n),n}spinner=createSpinner("",{color:"green"});logger=Ct({level:"silent",enabled:false});events=new EventEmitter;groupCache=new $e({stdTTL:300,useClones:false});collectors=new Map},a=new Ie;var w=o=>o,Ve=async()=>{try{return (await(await fetch("https://registry.npmjs.org/zaileys")).json())["dist-tags"].latest}catch(o){throw o}},Ke=async o=>{try{let e=`.session/${o}/creds.json`;await Pe.unlink(e);}catch(e){throw a.spinner.error(`Failed to remove auth creds for session "${o}"!`),e}},R=(o="")=>o?.length?o.normalize("NFKD").replace(/[\u0000-\u001F\u007F-\u009F\u200B-\u200F\u2028-\u202F\u2060-\u206F\uFEFF\uFFF9-\uFFFB]/gu,"").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u20D0-\u20FF\uFE20-\uFE2F]/gu,"").replace(/[\u202A-\u202E\u2066-\u2069]/gu,"").replace(/\u202E([\s\S]*?)\u202C?/gu,(t,i)=>[...i].reverse().join("")):null;var v=(o,e="lime")=>Array.isArray(e)?Ge(e)(o):Ge([e,e])(o),Ae=o=>{try{return JSON.parse(o)}catch{return b.attempt(()=>JSON.parse(JSON.stringify(o)||"{}"))}},te=o=>{try{return JSON.stringify(o)}catch{let e=b.attempt(()=>JSON.stringify(Ae(o)||"{}"));return b.isError(e)?"{}":e}},Vs=(o="")=>b.shuffle(o).join(""),se=(o="",e="")=>o?b.includes(o.toLowerCase(),e.toLowerCase()):null,He=(o="")=>o?b.castArray(o.match(URL_REGEX)||[]):[],Ks=o=>o[Math.floor(Math.random()*o.length)],I=(o,e)=>{for(let t of o||[])if(t&&typeof t=="object"){for(let i of e)if(i in t&&t[i]!==void 0&&t[i]!==null)return t[i]}},Ze=(o,e)=>{let t=b.castArray(e),i=(r,c)=>b.every(c,(l,p)=>r?.[p]===l),n=(r,c)=>b.some(c,(l,p)=>r?.[p]===l),s=r=>b.isArray(r)?b.find(r,s)??r:b.isObject(r)?b.find(t,p=>i(r,p))||b.find(t,p=>n(r,p))?r:b.find(b.values(r),s)??r:null;return s(o)},Gs=(o,e,t)=>new Proxy(o,{apply(i,n,s){e?.(s);let r=Reflect.apply(i,n,s);return t?t(r,s):r}});var F=o=>{let e;Array.isArray(o)?e=o.join("|"):typeof o=="string"?e=o:e=String(o);let t=2166136261,i=e.length;for(let n=0;n<i;n++)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return "Z4D3FC"+(t>>>0).toString(16).padStart(8,"0").toUpperCase()},Qe=(o="")=>{if(!o)return [];let e=new Set;for(let t of o.matchAll(/@(\d+)/g))e.add(t[1]);return b.toArray(e)},Ee=(o="")=>{if(!o)return [];let e=new Set;for(let t of o.matchAll(/@(\d+)/g))t[1].length<=15&&e.add(t[1]);return b.flatMap([...e],t=>[`${t}@s.whatsapp.net`,`${t}@g.us`,`${t}@lid`])},K=o=>b.isEmpty(o)?[]:b.map([...o],e=>`${e}@s.whatsapp.net`),Ye=o=>b.omit(o,["url","contextInfo","fileSha256","fileEncSha256","mediaKey","directPath","waveform","thumbnail","jpegThumbnail","thumbnailEncSha256","thumbnailSha256","thumbnailDirectPath","firstFrameSidecar","streamingSidecar","scansSidecar","callKey","message","key","midQualityFileSha256","historySyncNotification","appStateSyncKeyShare","appStateSyncKeyRequest","initialSecurityNotificationSettingSync","appStateFatalExceptionNotification","disappearingMode","peerDataOperationRequestMessage","peerDataOperationRequestResponseMessage","botFeedbackMessage"]),G=o=>{if(!o)return {leaf:void 0,chain:[]};let e=extractMessageContent(o)||o,t=[];for(;e&&typeof e=="object";){let i=getContentType(e);if(!i)break;t.push(i);let n=e[i];if(!n||typeof n!="object"){e=n;break}e=n;}return {leaf:e,chain:t}},L=o=>Number(o?.split("@")[0]);var Ot=qe("@ffmpeg-installer/ffmpeg").path,Dt=qe("@ffprobe-installer/ffprobe").path;H.setFfmpegPath(Ot);H.setFfprobePath(Dt);var h={OPUS:{CODEC:"libopus",CHANNELS:1,FREQUENCY:48e3,BITRATE:"48k",FORMAT:"ogg"},THUMBNAIL:{SIZE:100,QUALITY:50,TIMESTAMP:"10%"},STICKER:{SIZE:512,MAX_DURATION:10,FPS:15,DEFAULT_QUALITY:80,COMPRESSION_LEVEL:6},MIME:{AUDIO:"audio/",VIDEO:"video/",IMAGE:"image/",GIF:"image/gif",MP4:"video/mp4"}},k=class{static generateUniqueId(){return `${Date.now()}_${Math.random().toString(36).slice(2,11)}`}static createTempPath(e,t){return Le__default.join(tmpdir(),`${e}_${this.generateUniqueId()}.${t}`)}static async cleanup(e){await Promise.allSettled(e.map(t=>Pe.unlink(t)));}static async safeReadFile(e){try{return await Pe.readFile(e)}catch{throw new Error(`Failed to read file: ${e}`)}}static async safeWriteFile(e,t){try{await Pe.writeFile(e,t);}catch{throw new Error(`Failed to write file: ${e}`)}}},A=class{static async toBuffer(e){if(isBuffer(e))return e;if(isArrayBuffer(e))return Buffer.from(e);if(isString(e))return this.fromString(e);throw new Error("Invalid input type: expected string, Buffer, or ArrayBuffer")}static async fromString(e){return e.startsWith("http://")||e.startsWith("https://")?this.fromUrl(e):Buffer.from(e,"base64")}static async fromUrl(e){try{let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let i=await t.arrayBuffer();return Buffer.from(i)}catch(t){throw new Error(`Failed to fetch URL: ${t.message}`)}}},O=class{static validate(e,t){if(!e?.mime?.startsWith(t))throw new Error(`Invalid file type: expected ${t}*, got ${e?.mime||"unknown"}`)}static isMedia(e){return e.startsWith(h.MIME.IMAGE)||e.startsWith(h.MIME.VIDEO)}static isAnimated(e){return e===h.MIME.GIF||e.startsWith(h.MIME.VIDEO)}},Z=class{static async process(e){return new Promise((t,i)=>{let n=H(e.input).output(e.output);for(let s=0;s<e.options.length;s++){let r=e.options[s];r.startsWith("-")&&s+1<e.options.length&&!e.options[s+1].startsWith("-")?(n.outputOptions(r,e.options[s+1]),s++):n.outputOptions(r);}n.on("end",async()=>{try{await e.onEnd(),t();}catch(s){i(s);}}).on("error",async s=>{try{await e.onError(s);}finally{i(s);}}).run();})}static async getDuration(e){return new Promise((t,i)=>{H.ffprobe(e,(n,s)=>{if(n)return i(n);t(s.format.duration||0);});})}},ie=class{static async getWaAudio(e,t="opus"){let i=await A.toBuffer(e),n=await fileTypeFromBuffer(i);O.validate(n,h.MIME.AUDIO);let s=k.createTempPath("audio_in","wav"),r=t==="opus"?"ogg":"mp3",c=k.createTempPath("audio_out",r);await k.safeWriteFile(s,i);let l;try{let p=t==="opus"?["-vn","-c:a","libopus","-b:a","48k","-ac","1","-avoid_negative_ts","make_zero","-map_metadata","-1","-f","opus"]:["-vn","-c:a","libmp3lame","-b:a","128k","-ac","2","-avoid_negative_ts","make_zero","-map_metadata","-1","-f","mp3"];return await Z.process({input:s,output:c,options:p,onEnd:async()=>{l=await k.safeReadFile(c);},onError:async()=>{await k.cleanup([s,c]);}}),await k.cleanup([s,c]),l}catch(p){throw await k.cleanup([s,c]),new Error(`${t.toUpperCase()} conversion failed: ${p.message}`)}}},N=class{static async getThumbnail(e){let t=await A.toBuffer(e),i=await fileTypeFromBuffer(t);O.validate(i,h.MIME.VIDEO);let n=k.createTempPath("video","mp4"),s=k.createTempPath("thumb","jpg");await k.safeWriteFile(n,t);let r;try{return await new Promise((c,l)=>{H(n).screenshots({timestamps:[h.THUMBNAIL.TIMESTAMP],filename:Le__default.basename(s),folder:Le__default.dirname(s),size:`${h.THUMBNAIL.SIZE}x${h.THUMBNAIL.SIZE}`,quality:h.THUMBNAIL.QUALITY}).on("end",async()=>{try{r=(await k.safeReadFile(s)).toString("base64"),c();}catch(p){l(p);}}).on("error",l);}),await k.cleanup([n,s]),r}catch(c){throw await k.cleanup([n,s]),new Error(`Thumbnail generation failed: ${c.message}`)}}static async getDuration(e){return Z.getDuration(e)}},re=class{static async getThumbnail(e){return (await((await fileTypeFromBuffer(e)).mime===h.MIME.GIF?Re(e,{animated:false}):Re(e)).resize(h.THUMBNAIL.SIZE,h.THUMBNAIL.SIZE,{fit:"cover"}).jpeg({quality:h.THUMBNAIL.QUALITY}).toBuffer()).toString("base64")}static async resizeForSticker(e,t){return Re(e).resize(h.STICKER.SIZE,h.STICKER.SIZE,{fit:"cover",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:t}).toBuffer()}},Q=class{static async getThumbnail(e){let t=await A.toBuffer(e),i=await fileTypeFromBuffer(t);if(!i||!O.isMedia(i.mime))throw new Error("Invalid media type: expected image or video");return i.mime.startsWith(h.MIME.VIDEO)?N.getThumbnail(e):re.getThumbnail(t)}},ne=class{static createExifMetadata(e){let t={"sticker-pack-id":F(Date.now().toString()),"sticker-pack-name":e?.packageName||"Zaileys Library","sticker-pack-publisher":e?.authorName||"https://github.com/zeative/zaileys",emojis:["\u{1F913}"],"android-app-store-link":"https://play.google.com/store/apps/details?id=com.marsvard.stickermakerforwhatsapp","ios-app-store-link":"https://itunes.apple.com/app/sticker-maker-studio/id1443326857"},i=Buffer.from([73,73,42,0,8,0,0,0,1,0,65,87,7,0,0,0,0,0,22,0,0,0]),n=Buffer.from(JSON.stringify(t),"utf8"),s=Buffer.concat([i,n]);return s.writeUIntLE(n.length,14,4),s}static async processAnimated(e,t,i){let n=this.getExtension(t),s=k.createTempPath("sticker_in",n),r=k.createTempPath("sticker_out","webp");await k.safeWriteFile(s,e);let c=h.STICKER.MAX_DURATION;try{let T=await N.getDuration(s);c=w(Math.min(T,h.STICKER.MAX_DURATION));}catch{console.warn("Using default duration:",h.STICKER.MAX_DURATION);}let l=`scale=${h.STICKER.SIZE}:${h.STICKER.SIZE}:force_original_aspect_ratio=increase,crop=${h.STICKER.SIZE}:${h.STICKER.SIZE},fps=${h.STICKER.FPS},format=rgba`,p=Math.max(1,Math.min(100,100-i)),y;try{return await Z.process({input:s,output:r,options:["-vcodec libwebp",`-vf ${l}`,`-q:v ${p}`,"-loop 0","-preset default","-an","-vsync 0",`-t ${c}`,`-compression_level ${h.STICKER.COMPRESSION_LEVEL}`],onEnd:async()=>{y=await k.safeReadFile(r);},onError:async()=>{await k.cleanup([s,r]);}}),await k.cleanup([s,r]),y}catch(T){throw await k.cleanup([s,r]),new Error(`Animated sticker processing failed: ${T.message}`)}}static getExtension(e){return e===h.MIME.GIF?"gif":e.startsWith(h.MIME.VIDEO)?"mp4":"tmp"}static async create(e,t){try{let i=await A.toBuffer(e),n=await fileTypeFromBuffer(i);if(!n)throw new Error("Unable to detect file type");let s=t?.quality||h.STICKER.DEFAULT_QUALITY,c=O.isAnimated(n.mime)?await this.processAnimated(i,n.mime,s):await re.resizeForSticker(i,s),l=this.createExifMetadata(t),p=new Bt.Image;await p.load(c),p.exif=l;let y=await p.save(null);return Buffer.isBuffer(y)?y:Buffer.from(y)}catch(i){throw new Error(`Sticker creation failed: ${i.message||i}`)}}},oe=class{static async create(e){try{let t=await A.toBuffer(e),i=await fileTypeFromBuffer(t);if(!i)throw new Error("Unable to detect file type");return {document:t,mimetype:i.mime,fileName:F(Date.now().toString()),jpegThumbnail:await Q.getThumbnail(t)}}catch(t){throw new Error(`Document creation failed: ${t.message||t}`)}}},Xe=A.toBuffer.bind(A),et=ie.getWaAudio.bind(ie),mi=N.getThumbnail.bind(N),di=N.getDuration.bind(N),Ne=Q.getThumbnail.bind(Q),tt=ne.create.bind(ne),st=oe.create.bind(oe);var Oe=class o{static inst;fLocks=new Map;kLocks=new Map;maxSize=100;static get(){return this.inst||(this.inst=new o)}getFile(e){let t=this.fLocks.get(e);if(!t){if(this.fLocks.size>=this.maxSize){let i=this.fLocks.keys().next().value;this.fLocks.delete(i);}t=new Mutex,this.fLocks.set(e,t);}return t}getKey(e){let t=this.kLocks.get(e);if(!t){if(this.kLocks.size>=this.maxSize){let i=this.kLocks.keys().next().value;this.kLocks.delete(i);}t=new Mutex,this.kLocks.set(e,t);}return t}},De=class{data;path;pool;size;chunkDir;replacer;reviver;loaded=false;flushMode;debounceMs;flushTimer=null;dirty=false;constructor(e,t,i=2*1024*1024,n="debounce",s=200){this.data=new Map,this.path=e,this.pool=Oe.get(),this.size=i,this.chunkDir=`${e}.c`,this.replacer=t?.replacer||null,this.reviver=t?.reviver||null,this.flushMode=n,this.debounceMs=s;}async ensureLoaded(){this.loaded||(await this.read(),this.loaded=true);}scheduleFlush(){if(this.flushMode!=="manual"){if(this.flushMode==="sync"){this.write();return}this.dirty=true,!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.dirty&&(this.dirty=false,this.write());},this.debounceMs));}}async read(){return this.pool.getFile(this.path).runExclusive(async()=>{try{let t=await readFile(this.path,"utf-8"),i=JSON.parse(t,this.reviver);this.data.clear();let n=[];for(let[s,r]of Object.entries(i))this.isMeta(r)?n.push(this.loadChunk(s,r)):this.data.set(s,r);return await Promise.all(n),this.loaded=!0,this.data}catch{return await mkdir(dirname(this.path),{recursive:true}),this.data.clear(),this.loaded=true,this.data}})}async write(){return this.pool.getFile(this.path).runExclusive(async()=>{let t={},i=[];for(let[s,r]of this.data){if(this.isMeta(r)){t[s]=r;continue}JSON.stringify(r,this.replacer).length>this.size?i.push(this.saveChunk(s,r).then(l=>{t[s]=l;})):t[s]=r;}await Promise.all(i);let n=JSON.stringify(t,this.replacer,2);await writeFile(this.path,n,"utf-8");})}async set(e,t){await this.ensureLoaded(),await this.pool.getKey(e).runExclusive(async()=>{this.data.set(e,t),this.scheduleFlush();});}async push(e,t){await this.ensureLoaded(),await this.pool.getKey(e).runExclusive(async()=>{let n=this.data.get(e),s;Array.isArray(n)?s=n:n===void 0?s=[]:s=[n],s.push(t),this.data.set(e,s),this.scheduleFlush();});}async get(e){if(await this.ensureLoaded(),typeof e=="string")return this.data.get(e);let t=Array.from(this.data.values()).flat();return Ze(t,e)}async all(){return await this.ensureLoaded(),Array.from(this.data.entries())}async delete(e){return await this.ensureLoaded(),this.pool.getKey(e).runExclusive(async()=>{let i=this.data.get(e);this.isMeta(i)&&await this.delChunk(e,i);let n=this.data.delete(e);return this.scheduleFlush(),n})}async saveChunk(e,t){let i=JSON.stringify(t,this.replacer),n=Buffer.from(i,"utf-8"),s=Math.ceil(n.length/this.size);await mkdir(this.chunkDir,{recursive:true});let r={v:1,k:e,t:s,s:this.size,c:n.length,m:Date.now().toString(36)},c=[];for(let l=0;l<s;l++){let p=l*this.size,y=Math.min(p+this.size,n.length),T=n.subarray(p,y);c.push(writeFile(join(this.chunkDir,`${e}.${l}.json`),JSON.stringify({i:l,d:T.toString("base64")})));}return c.push(writeFile(join(this.chunkDir,`${e}.manifest.json`),JSON.stringify(r))),await Promise.all(c),{t:s,s:this.size,k:e}}async loadChunk(e,t){let i=join(this.chunkDir,`${e}.manifest.json`),n=JSON.parse(await readFile(i,"utf-8")),s=[];for(let p=0;p<n.t;p++)s.push(readFile(join(this.chunkDir,`${e}.${p}.json`),"utf-8").then(y=>Buffer.from(JSON.parse(y).d,"base64")));let r=await Promise.all(s),c=Buffer.concat(r),l=JSON.parse(c.toString("utf-8"),this.reviver);this.data.set(e,l);}async delChunk(e,t){let i=[];for(let n=0;n<t.t;n++)i.push(unlink(join(this.chunkDir,`${e}.${n}.json`)).catch(()=>{}));i.push(unlink(join(this.chunkDir,`${e}.manifest.json`)).catch(()=>{})),await Promise.all(i);try{(await readdir(this.chunkDir)).length===0&&await rmdir(this.chunkDir);}catch{}}isMeta(e){return e?.t&&e?.s&&e?.k}},q=(o,e)=>new De(o,e?.BufferJSON,e?.size,e?.flushMode,e?.debounceMs);var at=async o=>{a.spinner.start(" Initializing auth state...");let e=await stat(o).catch(()=>{});if(e){if(!e.isDirectory())throw a.spinner.error(` Failed to open credentials
|
|
2
|
-
`),`found something that is not a directory at ${o}, either delete it or specify a different location`}else await mkdir(o,{recursive:true});let t=
|
|
3
|
-
by ${ce.author} \xB7 v${ce.version}`,
|
|
4
|
-
`,
|
|
5
|
-
`),await n()),T&&await i();}if(r==="open")if(e.user?.id){let p=jidNormalizedUser(e.user.id).split("@")[0],y=e.user.name||e.user.verifiedName;a.spinner.success(` Connected as ${cristal(y||p)}`);}else a.spinner.success(" Connected!");a.events.emit("connection",t);}),e.ev.on("messaging-history.set",({progress:s})=>{t.status="syncing",t.syncProgress=s,a.spinner.start(" Syncing messages history..."),s&&a.spinner.update(` Syncing messages history ${s+"%"}`),s==100&&(a.spinner.success(" Syncing messages history completed!"),t.syncCompleted=true),a.events.emit("connection",t);});}};var dt={text:"text",conversation:"text",imageMessage:"image",contactMessage:"contact",locationMessage:"location",documentMessage:"document",audioMessage:"audio",videoMessage:"video",protocolMessage:"protocol",contactsArrayMessage:"contacts",highlyStructuredMessage:"highlyStructured",sendPaymentMessage:"sendPayment",liveLocationMessage:"location",requestPaymentMessage:"requestPayment",declinePaymentRequestMessage:"declinePaymentRequest",cancelPaymentRequestMessage:"cancelPaymentRequest",templateMessage:"template",stickerMessage:"sticker",groupInviteMessage:"groupInvite",templateButtonReplyMessage:"buttons",productMessage:"product",deviceSentMessage:"deviceSent",listMessage:"lists",viewOnceMessage:"viewOnce",orderMessage:"order",listResponseMessage:"lists",ephemeralMessage:"ephemeral",invoiceMessage:"invoice",buttonsMessage:"buttons",buttonsResponseMessage:"buttons",paymentInviteMessage:"paymentInvite",interactiveMessage:"interactive",reactionMessage:"reaction",stickerSyncRmrMessage:"sticker",questionMessage:"question",nativeFlowResponseMessage:"lists",interactiveResponseMessage:"interactiveResponse",pollCreationMessage:"pollCreation",pollCreationMessageKey:"pollUpdate",pollUpdateMessage:"pollUpdate",keepInChatMessage:"keepInChat",documentWithCaptionMessage:"document",requestPhoneNumberMessage:"requestPhoneNumber",viewOnceMessageV2:"viewOnce",encReactionMessage:"reaction",editedMessage:"text",viewOnceMessageV2Extension:"viewOnce",pollCreationMessageV2:"pollCreation",scheduledCallCreationMessage:"scheduledCallCreation",groupMentionedMessage:"groupMentioned",pinInChatMessage:"pinInChat",pollCreationMessageV3:"pollCreation",scheduledCallEditMessage:"scheduledCallEdit",ptvMessage:"ptv",botInvokeMessage:"botInvoke",callLogMesssage:"callLog",encCommentMessage:"encComment",bcallMessage:"bcall",lottieStickerMessage:"lottieSticker",eventMessage:"event",commentMessage:"comment",newsletterAdminInviteMessage:"text",extendedTextMessageWithParentKey:"text",extendedTextMessage:"text",placeholderMessage:"placeholder",encEventUpdateMessage:"encEventUpdate"},je={whatsapp:"0@s.whatsapp.net",meta:"13135550002@s.whatsapp.net",chatgpt:"18002428478@s.whatsapp.net",copilot:"18772241042@s.whatsapp.net",instagram:"447723442971@s.whatsapp.net",tiktok:"6285574670498@s.whatsapp.net"};var ue=class{constructor(e){this.client=e;this.limiter=new RateLimiterMemory({points:this.client.options.limiter?.maxMessages,duration:this.client.options.limiter?.durationMs/1e3});}limiter;async isSpam(e){try{return await this.limiter.consume(e),!1}catch{return true}}};var de=class{constructor(e){this.client=e;this.limiter=new ue(e),this.initialize();}limiter;maxReplies=3;async initialize(){let e=a.get("socket");e.ev.on("messages.upsert",async({messages:t,type:i})=>{if(i==="notify")for(let n of t){let s=await this.parse(n);s&&(this.client.collector.push(s)||(await this.client.middleware.run({messages:s}),await this.client.plugins.execute(this.client,{messages:s}),a.set("message",s),a.events.emit("messages",s)),this.client.options.autoRead&&await e.readMessages([s.message().key]));}});}async parse(e,t){if(e?.category==="peer"||!e?.message||!e?.key?.id||e?.messageStubType||e?.messageStubParameters?.length||e.message?.protocolMessage?.peerDataOperationRequestResponseMessage||e.message?.groupStatusMentionMessage)return;let i=e,n=a.get("socket"),s={},r=G(e.message),c=r.chain.at(-1),l=r.leaf;l?.message&&(r=G(l.message),c=r.chain.at(-1),l=r.leaf),s.uniqueId=null,s.channelId=null,s.chatId=e?.message?.protocolMessage?.key?.id||e?.key?.id||null,s.chatType=dt[c],s.receiverId=jidNormalizedUser(n?.user?.id||""),s.receiverName=R(n?.user?.name||n?.user?.verifiedName),s.roomId=jidNormalizedUser(e?.key?.remoteJid);let p=l?.type===0,y=l?.type===1,T=l?.type===2,ee=s.roomId?.includes("@newsletter"),Te=!!e?.message?.questionMessage,z=e?.key?.fromMe||false;if(z&&this.client.options.ignoreMe&&t!=="replied")return;let Se=l?.key?.id;if(p||y||T){let S=(await this.client.db("messages").get(s.roomId))?.find(B=>B.key.id===Se);if(!S)return;e=S,r=G(e.message),c=r.chain.at(-1),l=r.leaf;}if(s.roomName=await this.client.getRoomName(s.roomId),s.senderLid=I([e?.key],["remoteJidAlt","participant"])||null,s.senderId=jidNormalizedUser(e?.participant||e?.key?.participant||e?.key?.remoteJid),s.senderName=R(e?.pushName||e?.verifiedBizName),s.senderDevice=getDevice(s.chatId),s.channelId=F([s.roomId,s.senderId]),s.uniqueId=F([s.channelId,s.chatId]),s.timestamp=Number(e?.messageTimestamp)*1e3,ee){let C=await n.newsletterMetadata("jid",s.roomId);s.roomName=w(C.thread_metadata.name)?.text,s.senderId=null,s.senderLid=null;}if(z&&(s.senderLid=jidNormalizedUser(n.user.lid),s.senderId=s.receiverId,s.senderName=s.receiverName),s.text=l?.text||l?.caption||l?.name||l?.displayName||l?.conversation||l?.contentText||l?.selectedDisplayText||l||null,l?.name=="menu_options"&&(s.text=Ae(l?.paramsJson)?.id),s.text=R(s.text),s.mentions=Qe(s.text),s.links=He(s.text||""),s.isBot=s.chatId.startsWith("BAE5")||s.chatId.startsWith("3EB0")||s.chatId.startsWith("Z4D3FC"),s.isFromMe=z,s.isTagMe=s.mentions?.includes(s.receiverId.split("@")[0]),s.isPrefix=s.text?.startsWith(this.client.options?.prefix)||false,s.isSpam=await this.limiter.isSpam(s.channelId),s.isGroup=s.roomId?.includes("@g.us"),s.isNewsletter=ee,s.isQuestion=Te,s.isStory=s.roomId?.includes("@broadcast"),s.isViewOnce=false,s.isEdited=!!se(te(r),"editedMessage"),s.isDeleted=p,s.isPinned=y,s.isUnPinned=T,s.isBroadcast=!!e?.broadcast,s.isEphemeral=!!se(te(l?.contextInfo),"ephemeralSettingTimestamp"),s.isForwarded=!!se(te(l?.contextInfo),"forwardingScore"),s.citation=null,this.client.options.citation){s.citation=s.citation||{};let C=this.client.options.citation;for(let S of Object.keys(C)){let B=C[S];s.citation[S]=async()=>{let U=await B(),Ce=[L(s.roomId),L(s.senderLid),L(s.senderId)];return !!b.intersection(Ce,U).length};}}s.chatType!=="text"&&(s.media={...Ye(l),buffer:()=>downloadMediaMessage(e,"buffer",{}),stream:()=>downloadMediaMessage(e,"stream",{})}),s.message=()=>i,s.replied=null;let j=l?.contextInfo?.quotedMessage,_=I([j],["viewOnceMessageV2Extension","viewOnceMessage"]),W=l?.contextInfo?.stanzaId;if(j&&!this.maxReplies){this.maxReplies--;let S=(await this.client.db("messages").get(s.roomId))?.find(U=>U.key.id===W),B={...S,...G(_).leaf};_?(s.replied=await this.parse(B,"replied"),s.replied.isViewOnce=true):s.replied=await this.parse(S,"replied"),this.maxReplies=3;}return this.client.logs.message(s),s}};var fe=class{constructor(e){this.client=e;this.connection=new pe(e),this.messages=new de(e),this.calls=new ae(e),this.initialize();}connection;messages;calls;async initialize(){let e=a.get("socket");e.ev.on("groups.update",async([t])=>{let i=await e.groupMetadata(t.id);a.groupCache.set(t.id,i);}),e.ev.on("group-participants.update",async t=>{let i=await e.groupMetadata(t.id);a.groupCache.set(t.id,i);}),e?.ev.on("messaging-history.set",async t=>{let{chats:i,contacts:n,messages:s}=t;for(let r of i)await this.client.db("chats").push(r.id,r);for(let r of n)await this.client.db("contacts").push(r.id,r);for(let r of s){if(!r.message&&!r.key.isViewOnce||r?.category==="peer"||r.message?.protocolMessage||r.message?.groupStatusMentionMessage)return;await this.client.db("messages").push(r.key.remoteJid,r);}}),e?.ev.on("messages.upsert",async({messages:t})=>{for(let i of t){if(!i.message&&!i.key.isViewOnce||i?.category==="peer"||i.message?.protocolMessage||i.message?.groupStatusMentionMessage)return;await this.client.db("messages").push(i.key.remoteJid,i);}}),e?.ev.on("chats.upsert",async t=>{for(let i of t)await this.client.db("chats").push(i.id,i);}),e?.ev.on("contacts.upsert",async t=>{for(let i of t)await this.client.db("contacts").push(i.id,i);});}};var Y=(o,e)=>{let t=o.safeParse(e);if(t.success)return t.data;throw console.error(t.error),"Invalid data"};var rs=u.object({type:u.literal("quick_reply"),text:u.string()}),ns=u.object({type:u.literal("cta_url"),url:u.url(),text:u.string()}),os=u.object({type:u.literal("cta_copy"),copy:u.string(),text:u.string()}),as=u.object({type:u.literal("cta_call"),text:u.string(),phoneNumber:u.string()}),cs=u.object({type:u.literal("single_select"),text:u.string(),section:u.object({title:u.string(),rows:u.object({id:u.string(),title:u.string(),header:u.string().optional(),description:u.string().optional()}).array()}).array()}),ls=u.object({type:u.literal("interactive"),footer:u.string().optional(),data:u.union([rs,ns,os,as,cs]).array()}),ps=u.object({type:u.literal("simple"),footer:u.string().optional(),data:u.object({id:u.string(),text:u.string()}).array()}),gt=u.union([ps,ls]);var X=u.url().or(u.base64()).or(u.instanceof(Buffer)),ht=u.object({text:u.string()}).passthrough(),us=u.object({image:X,caption:u.string().optional()}).passthrough(),ms=u.object({audio:X,caption:u.string().optional(),ptt:u.boolean().optional()}).passthrough(),ds=u.object({video:X,caption:u.string().optional(),ptv:u.boolean().optional()}).passthrough(),fs=u.object({sticker:X,caption:u.string().optional()}).passthrough(),gs=u.object({document:X,caption:u.string().optional(),fileName:u.string().optional()}).passthrough(),hs=u.object({location:u.object({latitude:u.number(),longitude:u.number(),url:u.url().optional(),title:u.string().optional(),footer:u.string().optional()}).optional()}).passthrough(),ys=u.object({title:u.string().optional(),contacts:u.object({fullname:u.string(),phoneNumber:u.number(),organization:u.string().optional()}).array()}),ws=u.object({poll:u.object({name:u.string(),answers:u.string().array(),isMultiple:u.boolean().default(false).optional()})}),yt=u.object({replied:u.custom().optional(),isForwardedMany:u.boolean().optional(),isViewOnce:u.boolean().optional(),banner:u.custom().optional(),buttons:gt.optional()});u.enum(["forward","button","edit","delete"]);var Ms=u.union([ht,us,ms,ds,fs,gs,hs,ys,ws]),wt=u.string().or(u.intersection(Ms,yt.omit({buttons:true}))),Mt=u.intersection(ht,yt.omit({banner:true}));var ge=class{toNativeSimple(e){return e.map(({id:t,text:i})=>({name:"quick_reply",buttonParamsJson:JSON.stringify({display_text:i,id:t})}))}toNativeInteractive(e){let t={quick_reply:i=>({display_text:i.text,id:i.id}),cta_url:i=>({display_text:i.text,url:i.url,merchant_url:i.url}),cta_copy:i=>({display_text:i.text,id:i.id,copy_code:i.copy}),cta_call:i=>({display_text:i.text,phone_number:i.phoneNumber}),single_select:i=>({title:i.text,sections:i.section})};return e.map(i=>({name:i.type,buttonParamsJson:JSON.stringify(t[i.type](i))}))}build(e){let t=w(e).buttons,i=t?.data||[],s=t?.type=="simple"?this.toNativeSimple(i):this.toNativeInteractive(i);return {body:{text:w(e).text},footer:t.footer?{text:t.footer}:void 0,nativeFlowMessage:{buttons:s}}}async send(e,t,i){let n=a.get("socket"),s=n.authState?.creds?.me?.id||n.user?.id,r=this.build(t),c=generateWAMessageFromContent(e,{interactiveMessage:r},{userJid:s,messageId:generateMessageIDV2(s),...i});return await n.relayMessage(e,c.message,{messageId:c.key.id,...i,additionalNodes:[{tag:"biz",attrs:{},content:[{tag:"interactive",attrs:{type:"native_flow",v:"1"},content:[{tag:"native_flow",attrs:{v:"9",name:"mixed"}}]}]}]}),n.config?.emitOwnEvents&&!isJidGroup(e)&&process.nextTick(()=>n.upsertMessage?.(c,"append")),c}};var he=class{constructor(e){this.client=e;}async signal(e,t,i,n){i!="delete"&&(i=="button"?t=Y(Mt,t):t=Y(wt,t));let s=a.get("socket"),r={},c={},l=b.isString(t),p=this.client.options?.fakeReply?.provider,y=this.client.options?.autoMentions,T=this.client.options?.autoPresence,ee=b.has(t,"replied"),Te=b.has(t,"banner"),z=b.has(t,"isViewOnce"),Se=i=="button",j=b.has(t,"image"),_=b.has(t,"video"),W=b.has(t,"audio"),C=b.has(t,"sticker"),S=b.has(t,"document"),B=b.has(t,"location"),U=b.has(t,"contacts"),Ce=b.has(t,"poll"),Ue=j||_||W||C||S,J=l?t:I([t],["text","caption"]);if(T&&(W?await s.sendPresenceUpdate("recording",e):await s.sendPresenceUpdate("composing",e)),y&&(r={...r,mentions:Ee(J),contextInfo:{mentionedJid:Ee(J)}}),ee&&(c.quoted=w(t).replied,p&&(c.quoted.key.remoteJid=je[p],c.quoted.key.participant=je[p])),Te&&(r={...r,contextInfo:{externalAdReply:w(t).banner}},r.contextInfo.externalAdReply.mediaType=1),z&&(r={...r,viewOnce:w(t)?.isViewOnce}),J&&(r={...r,text:J,caption:J},Ue&&delete w(r).text),Ue){let M=I([t],["image","video","audio","sticker","document"]),E=b.isString(M)?{url:M}:M;if(j&&(r={...r,image:E,jpegThumbnail:await Ne(M)}),_){let P=w(t)?.ptv;r={...r,video:E,ptv:P,jpegThumbnail:await Ne(M)};}if(W){let P=w(t)?.ptt;r={...r,audio:await et(M),ptt:P,mimetype:P?"audio/ogg; codecs=opus":"audio/mpeg"};}if(C&&(r={...r,sticker:await tt(M,this.client.options?.sticker)}),S){let P=await st(M);r={...r,fileName:w(t).fileName,...P};}}if(B){let M=w(t).location;r={...r,location:{degreesLatitude:M.latitude,degreesLongitude:M.longitude,url:M.url,address:M.footer,name:M.title}};}if(U){let M=w(t)?.contacts,Je=M?.contacts.map(E=>{let P=["BEGIN:VCARD","VERSION:3.0",`FN:${E.fullname}`,`ORG:${E.organization||""}`,`TEL;type=CELL;type=VOICE;waid=${E.phoneNumber}:${E.phoneNumber}`,"END:VCARD"].join(`
|
|
6
|
-
`);return {displayName:
|
|
7
|
-
`;e?.isNewsletter?
|
|
8
|
-
`:
|
|
9
|
-
`,
|
|
10
|
-
`,
|
|
11
|
-
`;
|
|
12
|
-
`,
|
|
13
|
-
`,
|
|
1
|
+
import Xt,{URL_REGEX,extractMessageContent,getContentType,BufferJSON,initAuthCreds,proto,makeCacheableSignalKeyStore,isJidBroadcast,generateWAMessageFromContent,generateMessageIDV2,isJidGroup,delay,DisconnectReason,jidNormalizedUser,getDevice,downloadMediaMessage}from'baileys';import Le,{readFile,mkdir,writeFile,unlink,readdir,rmdir,stat}from'fs/promises';import {Mutex}from'async-mutex';import*as Ne from'path';import Ne__default,{dirname,join}from'path';import {createSpinner}from'nanospinner';import je from'node-cache';import {EventEmitter}from'events';import Et from'pino';import et,{cristal}from'gradient-string';import b,{isBuffer,isArrayBuffer,isString}from'lodash';import {fileTypeFromBuffer}from'file-type';import K from'fluent-ffmpeg';import $t from'node-webpmux';import {tmpdir}from'os';import Be from'sharp';import ts from'figlet';import is from'qrcode-terminal';import {RateLimiterMemory}from'rate-limiter-flexible';import u,{z}from'zod';import*as be from'fs';import {pathToFileURL}from'url';var Qe=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Re=class{data=new Map;cache=new Map;set(e,t){this.data.set(e,{...this.data.get(e),...t});}get(e){return this.data.get(e)||{}}update(e,t){let s=this.get(e);this.set(e,t(s));}delete(e){this.data.delete(e);}has(e){return this.data.has(e)}lowdb(e,t){let s=`.session/${e}/${t}`;if(this.cache.has(s))return this.cache.get(s);let r=V(s);return this.cache.set(s,r),r}spinner=createSpinner("",{color:"green"});logger=Et({level:"silent",enabled:false});events=new EventEmitter;groupCache=new je({stdTTL:300,useClones:false});collectors=new Map},a=new Re;var y=o=>o,Ye=async()=>{try{return (await(await fetch("https://registry.npmjs.org/zaileys")).json())["dist-tags"].latest}catch(o){throw o}},Xe=async o=>{try{let e=`.session/${o}/creds.json`;await Le.unlink(e);}catch(e){throw a.spinner.error(`Failed to remove auth creds for session "${o}"!`),e}},E=(o="")=>o?.length?o.normalize("NFKD").replace(/[\u0000-\u001F\u007F-\u009F\u200B-\u200F\u2028-\u202F\u2060-\u206F\uFEFF\uFFF9-\uFFFB]/gu,"").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u20D0-\u20FF\uFE20-\uFE2F]/gu,"").replace(/[\u202A-\u202E\u2066-\u2069]/gu,"").replace(/\u202E([\s\S]*?)\u202C?/gu,(t,s)=>[...s].reverse().join("")):null;var v=(o,e="lime")=>Array.isArray(e)?et(e)(o):et([e,e])(o),Ee=o=>{try{return JSON.parse(o)}catch{return b.attempt(()=>JSON.parse(JSON.stringify(o)||"{}"))}},ee=o=>{try{return JSON.stringify(o)}catch{let e=b.attempt(()=>JSON.stringify(Ee(o)||"{}"));return b.isError(e)?"{}":e}},Qs=(o="")=>b.shuffle(o).join(""),te=(o="",e="")=>o?b.includes(o.toLowerCase(),e.toLowerCase()):null,tt=(o="")=>o?b.castArray(o.match(URL_REGEX)||[]):[],Ys=o=>o[Math.floor(Math.random()*o.length)],A=(o,e)=>{for(let t of o||[])if(t&&typeof t=="object"){for(let s of e)if(s in t&&t[s]!==void 0&&t[s]!==null)return t[s]}},st=(o,e)=>{let t=b.castArray(e),s=(n,c)=>b.every(c,(p,l)=>n?.[l]===p),r=(n,c)=>b.some(c,(p,l)=>n?.[l]===p),i=n=>b.isArray(n)?b.find(n,i)??n:b.isObject(n)?b.find(t,l=>s(n,l))||b.find(t,l=>r(n,l))?n:b.find(b.values(n),i)??n:null;return i(o)},Xs=(o,e,t)=>new Proxy(o,{apply(s,r,i){e?.(i);let n=Reflect.apply(s,r,i);return t?t(n,i):n}});var N=o=>{let e;Array.isArray(o)?e=o.join("|"):typeof o=="string"?e=o:e=String(o);let t=2166136261,s=e.length;for(let r=0;r<s;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return "Z4D3FC"+(t>>>0).toString(16).padStart(8,"0").toUpperCase()},it=(o="")=>{if(!o)return [];let e=new Set;for(let t of o.matchAll(/@(\d+)/g))e.add(t[1]);return b.toArray(e)},We=(o="")=>{if(!o)return [];let e=new Set;for(let t of o.matchAll(/@(\d+)/g))t[1].length<=15&&e.add(t[1]);return b.flatMap([...e],t=>[`${t}@s.whatsapp.net`,`${t}@g.us`,`${t}@lid`])},ni=o=>b.isEmpty(o)?[]:b.map([...o],e=>`${e}@s.whatsapp.net`),rt=o=>b.omit(o,["url","contextInfo","fileSha256","fileEncSha256","mediaKey","directPath","waveform","thumbnail","jpegThumbnail","thumbnailEncSha256","thumbnailSha256","thumbnailDirectPath","firstFrameSidecar","streamingSidecar","scansSidecar","callKey","message","key","midQualityFileSha256","historySyncNotification","appStateSyncKeyShare","appStateSyncKeyRequest","initialSecurityNotificationSettingSync","appStateFatalExceptionNotification","disappearingMode","peerDataOperationRequestMessage","peerDataOperationRequestResponseMessage","botFeedbackMessage"]),G=o=>{if(!o)return {leaf:void 0,chain:[]};let e=extractMessageContent(o)||o,t=[];for(;e&&typeof e=="object";){let s=getContentType(e);if(!s)break;t.push(s);let r=e[s];if(!r||typeof r!="object"){e=r;break}e=r;}return {leaf:e,chain:t}},W=o=>Number(o?.split("@")[0]);var jt=Qe("@ffmpeg-installer/ffmpeg").path,_t=Qe("@ffprobe-installer/ffprobe").path;K.setFfmpegPath(jt);K.setFfprobePath(_t);var h={OPUS:{CODEC:"libopus",CHANNELS:1,FREQUENCY:48e3,BITRATE:"48k",FORMAT:"ogg"},THUMBNAIL:{SIZE:100,QUALITY:50,TIMESTAMP:"10%"},STICKER:{SIZE:512,MAX_DURATION:10,FPS:15,DEFAULT_QUALITY:80,COMPRESSION_LEVEL:6},MIME:{AUDIO:"audio/",VIDEO:"video/",IMAGE:"image/",GIF:"image/gif",MP4:"video/mp4"}},M=class{static generateUniqueId(){return `${Date.now()}_${Math.random().toString(36).slice(2,11)}`}static createTempPath(e,t){return Ne__default.join(tmpdir(),`${e}_${this.generateUniqueId()}.${t}`)}static async cleanup(e){await Promise.allSettled(e.map(t=>Le.unlink(t)));}static async safeReadFile(e){try{return await Le.readFile(e)}catch{throw new Error(`Failed to read file: ${e}`)}}static async safeWriteFile(e,t){try{await Le.writeFile(e,t);}catch{throw new Error(`Failed to write file: ${e}`)}}},I=class{static async toBuffer(e){if(isBuffer(e))return e;if(isArrayBuffer(e))return Buffer.from(e);if(isString(e))return this.fromString(e);throw new Error("Invalid input type: expected string, Buffer, or ArrayBuffer")}static async fromString(e){return e.startsWith("http://")||e.startsWith("https://")?this.fromUrl(e):Buffer.from(e,"base64")}static async fromUrl(e){try{let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let s=await t.arrayBuffer();return Buffer.from(s)}catch(t){throw new Error(`Failed to fetch URL: ${t.message}`)}}},D=class{static validate(e,t){if(!e?.mime?.startsWith(t))throw new Error(`Invalid file type: expected ${t}*, got ${e?.mime||"unknown"}`)}static isMedia(e){return e.startsWith(h.MIME.IMAGE)||e.startsWith(h.MIME.VIDEO)}static isAnimated(e){return e===h.MIME.GIF||e.startsWith(h.MIME.VIDEO)}},H=class{static async process(e){return new Promise((t,s)=>{let r=K(e.input).output(e.output);for(let i=0;i<e.options.length;i++){let n=e.options[i];n.startsWith("-")&&i+1<e.options.length&&!e.options[i+1].startsWith("-")?(r.outputOptions(n,e.options[i+1]),i++):r.outputOptions(n);}r.on("end",async()=>{try{await e.onEnd(),t();}catch(i){s(i);}}).on("error",async i=>{try{await e.onError(i);}finally{s(i);}}).run();})}static async getDuration(e){return new Promise((t,s)=>{K.ffprobe(e,(r,i)=>{if(r)return s(r);t(i.format.duration||0);});})}},se=class{static async getWaAudio(e,t="opus"){let s=await I.toBuffer(e),r=await fileTypeFromBuffer(s);D.validate(r,h.MIME.AUDIO);let i=M.createTempPath("audio_in","wav"),n=t==="opus"?"ogg":"mp3",c=M.createTempPath("audio_out",n);await M.safeWriteFile(i,s);let p;try{let l=t==="opus"?["-vn","-c:a","libopus","-b:a","48k","-ac","1","-avoid_negative_ts","make_zero","-map_metadata","-1","-f","opus"]:["-vn","-c:a","libmp3lame","-b:a","128k","-ac","2","-avoid_negative_ts","make_zero","-map_metadata","-1","-f","mp3"];return await H.process({input:i,output:c,options:l,onEnd:async()=>{p=await M.safeReadFile(c);},onError:async()=>{await M.cleanup([i,c]);}}),await M.cleanup([i,c]),p}catch(l){throw await M.cleanup([i,c]),new Error(`${t.toUpperCase()} conversion failed: ${l.message}`)}}},L=class{static async getThumbnail(e){let t=await I.toBuffer(e),s=await fileTypeFromBuffer(t);D.validate(s,h.MIME.VIDEO);let r=M.createTempPath("video","mp4"),i=M.createTempPath("thumb","jpg");await M.safeWriteFile(r,t);let n;try{return await new Promise((c,p)=>{K(r).screenshots({timestamps:[h.THUMBNAIL.TIMESTAMP],filename:Ne__default.basename(i),folder:Ne__default.dirname(i),size:`${h.THUMBNAIL.SIZE}x${h.THUMBNAIL.SIZE}`,quality:h.THUMBNAIL.QUALITY}).on("end",async()=>{try{n=(await M.safeReadFile(i)).toString("base64"),c();}catch(l){p(l);}}).on("error",p);}),await M.cleanup([r,i]),n}catch(c){throw await M.cleanup([r,i]),new Error(`Thumbnail generation failed: ${c.message}`)}}static async getDuration(e){return H.getDuration(e)}},ie=class{static async getThumbnail(e){return (await((await fileTypeFromBuffer(e)).mime===h.MIME.GIF?Be(e,{animated:false}):Be(e)).resize(h.THUMBNAIL.SIZE,h.THUMBNAIL.SIZE,{fit:"cover"}).jpeg({quality:h.THUMBNAIL.QUALITY}).toBuffer()).toString("base64")}static async resizeForSticker(e,t){return Be(e).resize(h.STICKER.SIZE,h.STICKER.SIZE,{fit:"cover",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:t}).toBuffer()}},Z=class{static async getThumbnail(e){let t=await I.toBuffer(e),s=await fileTypeFromBuffer(t);if(!s||!D.isMedia(s.mime))throw new Error("Invalid media type: expected image or video");return s.mime.startsWith(h.MIME.VIDEO)?L.getThumbnail(e):ie.getThumbnail(t)}},re=class{static createExifMetadata(e){let t={"sticker-pack-id":N(Date.now().toString()),"sticker-pack-name":e?.packageName||"Zaileys Library","sticker-pack-publisher":e?.authorName||"https://github.com/zeative/zaileys",emojis:["\u{1F913}"],"android-app-store-link":"https://play.google.com/store/apps/details?id=com.marsvard.stickermakerforwhatsapp","ios-app-store-link":"https://itunes.apple.com/app/sticker-maker-studio/id1443326857"},s=Buffer.from([73,73,42,0,8,0,0,0,1,0,65,87,7,0,0,0,0,0,22,0,0,0]),r=Buffer.from(JSON.stringify(t),"utf8"),i=Buffer.concat([s,r]);return i.writeUIntLE(r.length,14,4),i}static async processAnimated(e,t,s){let r=this.getExtension(t),i=M.createTempPath("sticker_in",r),n=M.createTempPath("sticker_out","webp");await M.safeWriteFile(i,e);let c=h.STICKER.MAX_DURATION;try{let x=await L.getDuration(i);c=y(Math.min(x,h.STICKER.MAX_DURATION));}catch{console.warn("Using default duration:",h.STICKER.MAX_DURATION);}let p=`scale=${h.STICKER.SIZE}:${h.STICKER.SIZE}:force_original_aspect_ratio=increase,crop=${h.STICKER.SIZE}:${h.STICKER.SIZE},fps=${h.STICKER.FPS},format=rgba`,l=Math.max(1,Math.min(100,100-s)),k;try{return await H.process({input:i,output:n,options:["-vcodec libwebp",`-vf ${p}`,`-q:v ${l}`,"-loop 0","-preset default","-an","-vsync 0",`-t ${c}`,`-compression_level ${h.STICKER.COMPRESSION_LEVEL}`],onEnd:async()=>{k=await M.safeReadFile(n);},onError:async()=>{await M.cleanup([i,n]);}}),await M.cleanup([i,n]),k}catch(x){throw await M.cleanup([i,n]),new Error(`Animated sticker processing failed: ${x.message}`)}}static getExtension(e){return e===h.MIME.GIF?"gif":e.startsWith(h.MIME.VIDEO)?"mp4":"tmp"}static async create(e,t){try{let s=await I.toBuffer(e),r=await fileTypeFromBuffer(s);if(!r)throw new Error("Unable to detect file type");let i=t?.quality||h.STICKER.DEFAULT_QUALITY,c=D.isAnimated(r.mime)?await this.processAnimated(s,r.mime,i):await ie.resizeForSticker(s,i),p=this.createExifMetadata(t),l=new $t.Image;await l.load(c),l.exif=p;let k=await l.save(null);return Buffer.isBuffer(k)?k:Buffer.from(k)}catch(s){throw new Error(`Sticker creation failed: ${s.message||s}`)}}},ne=class{static async create(e){try{let t=await I.toBuffer(e),s=await fileTypeFromBuffer(t);if(!s)throw new Error("Unable to detect file type");return {document:t,mimetype:s.mime,fileName:N(Date.now().toString()),jpegThumbnail:await Z.getThumbnail(t)}}catch(t){throw new Error(`Document creation failed: ${t.message||t}`)}}},oe=I.toBuffer.bind(I),nt=se.getWaAudio.bind(se),ki=L.getThumbnail.bind(L),wi=L.getDuration.bind(L),De=Z.getThumbnail.bind(Z),ot=re.create.bind(re),at=ne.create.bind(ne);var $e=class o{static inst;fLocks=new Map;kLocks=new Map;maxSize=100;static get(){return this.inst||(this.inst=new o)}getFile(e){let t=this.fLocks.get(e);if(!t){if(this.fLocks.size>=this.maxSize){let s=this.fLocks.keys().next().value;this.fLocks.delete(s);}t=new Mutex,this.fLocks.set(e,t);}return t}getKey(e){let t=this.kLocks.get(e);if(!t){if(this.kLocks.size>=this.maxSize){let s=this.kLocks.keys().next().value;this.kLocks.delete(s);}t=new Mutex,this.kLocks.set(e,t);}return t}},ze=class{data;path;pool;size;chunkDir;replacer;reviver;loaded=false;flushMode;debounceMs;flushTimer=null;dirty=false;constructor(e,t,s=2*1024*1024,r="debounce",i=200){this.data=new Map,this.path=e,this.pool=$e.get(),this.size=s,this.chunkDir=`${e}.c`,this.replacer=t?.replacer||null,this.reviver=t?.reviver||null,this.flushMode=r,this.debounceMs=i;}async ensureLoaded(){this.loaded||(await this.read(),this.loaded=true);}scheduleFlush(){if(this.flushMode!=="manual"){if(this.flushMode==="sync"){this.write();return}this.dirty=true,!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.dirty&&(this.dirty=false,this.write());},this.debounceMs));}}async read(){return this.pool.getFile(this.path).runExclusive(async()=>{try{let t=await readFile(this.path,"utf-8"),s=JSON.parse(t,this.reviver);this.data.clear();let r=[];for(let[i,n]of Object.entries(s))this.isMeta(n)?r.push(this.loadChunk(i,n)):this.data.set(i,n);return await Promise.all(r),this.loaded=!0,this.data}catch{return await mkdir(dirname(this.path),{recursive:true}),this.data.clear(),this.loaded=true,this.data}})}async write(){return this.pool.getFile(this.path).runExclusive(async()=>{let t={},s=[];for(let[i,n]of this.data){if(this.isMeta(n)){t[i]=n;continue}JSON.stringify(n,this.replacer).length>this.size?s.push(this.saveChunk(i,n).then(p=>{t[i]=p;})):t[i]=n;}await Promise.all(s);let r=JSON.stringify(t,this.replacer,2);await writeFile(this.path,r,"utf-8");})}async set(e,t){await this.ensureLoaded(),await this.pool.getKey(e).runExclusive(async()=>{this.data.set(e,t),this.scheduleFlush();});}async push(e,t){await this.ensureLoaded(),await this.pool.getKey(e).runExclusive(async()=>{let r=this.data.get(e),i;Array.isArray(r)?i=r:r===void 0?i=[]:i=[r],i.push(t),this.data.set(e,i),this.scheduleFlush();});}async get(e){if(await this.ensureLoaded(),typeof e=="string")return this.data.get(e);let t=Array.from(this.data.values()).flat();return st(t,e)}async all(){return await this.ensureLoaded(),Array.from(this.data.entries())}async delete(e){return await this.ensureLoaded(),this.pool.getKey(e).runExclusive(async()=>{let s=this.data.get(e);this.isMeta(s)&&await this.delChunk(e,s);let r=this.data.delete(e);return this.scheduleFlush(),r})}async saveChunk(e,t){let s=JSON.stringify(t,this.replacer),r=Buffer.from(s,"utf-8"),i=Math.ceil(r.length/this.size);await mkdir(this.chunkDir,{recursive:true});let n={v:1,k:e,t:i,s:this.size,c:r.length,m:Date.now().toString(36)},c=[];for(let p=0;p<i;p++){let l=p*this.size,k=Math.min(l+this.size,r.length),x=r.subarray(l,k);c.push(writeFile(join(this.chunkDir,`${e}.${p}.json`),JSON.stringify({i:p,d:x.toString("base64")})));}return c.push(writeFile(join(this.chunkDir,`${e}.manifest.json`),JSON.stringify(n))),await Promise.all(c),{t:i,s:this.size,k:e}}async loadChunk(e,t){let s=join(this.chunkDir,`${e}.manifest.json`),r=JSON.parse(await readFile(s,"utf-8")),i=[];for(let l=0;l<r.t;l++)i.push(readFile(join(this.chunkDir,`${e}.${l}.json`),"utf-8").then(k=>Buffer.from(JSON.parse(k).d,"base64")));let n=await Promise.all(i),c=Buffer.concat(n),p=JSON.parse(c.toString("utf-8"),this.reviver);this.data.set(e,p);}async delChunk(e,t){let s=[];for(let r=0;r<t.t;r++)s.push(unlink(join(this.chunkDir,`${e}.${r}.json`)).catch(()=>{}));s.push(unlink(join(this.chunkDir,`${e}.manifest.json`)).catch(()=>{})),await Promise.all(s);try{(await readdir(this.chunkDir)).length===0&&await rmdir(this.chunkDir);}catch{}}isMeta(e){return e?.t&&e?.s&&e?.k}},V=(o,e)=>new ze(o,e?.BufferJSON,e?.size,e?.flushMode,e?.debounceMs);var mt=async o=>{a.spinner.start(" Initializing auth state...");let e=await stat(o).catch(()=>{});if(e){if(!e.isDirectory())throw a.spinner.error(` Failed to open credentials
|
|
2
|
+
`),`found something that is not a directory at ${o}, either delete it or specify a different location`}else await mkdir(o,{recursive:true});let t=V(`${o}/auth/creds.json`,{BufferJSON:BufferJSON}),s=V(`${o}/auth/keys.json`,{BufferJSON:BufferJSON,size:512*1024});await Promise.all([t.read(),s.read()]);let r=await t.get("creds")||initAuthCreds();return a.spinner.success(" Generate auth successfully"),{state:{creds:r,keys:{get:async(i,n)=>{let c={};return await Promise.all(n.map(async p=>{let l=`${i}:${p}`,k=await s.get(l);i==="app-state-sync-key"&&k&&(k=proto.Message.AppStateSyncKeyData.fromObject(k)),c[p]=k;})),c},set:async i=>{let n=[];for(let c in i)for(let p in i[c]){let l=i[c][p],k=`${c}:${p}`;l?n.push(s.set(k,l)):n.push(s.delete(k).then(()=>{}));}await Promise.all(n),await s.write();}}},saveCreds:async()=>{await t.set("creds",r),await t.write();}}};var Yt=new je,dt=(o,e)=>({logger:a.logger,printQRInTerminal:false,defaultQueryTimeoutMs:void 0,markOnlineOnConnect:o.options.autoOnline,syncFullHistory:o.options.syncFullHistory,msgRetryCounterCache:new je,mediaCache:new je({stdTTL:60}),cachedGroupMetadata:async t=>Yt.get(t),shouldIgnoreJid:t=>isJidBroadcast(t),auth:{creds:e.creds,keys:makeCacheableSignalKeyStore(e.keys,a.logger)},getMessage:async t=>{if(t?.id)return await o.db("messages").get(t.id)}});var ft=async o=>{let e=`.session/${o.options.session}`;console.info=()=>{};let{state:t,saveCreds:s}=await mt(e),r=dt(o,t),i=Xt(r);i.ev.on("creds.update",s),a.set("socket",i);};var ae=class{constructor(e){this.client=e;this.initialize();}async initialize(){let e=a.get("socket");e.ev.on("call",async t=>{for(let s of t){let r=await this.parse(s);r&&(await this.client.middleware.run({calls:r}),await this.client.plugins.execute(this.client,{messages:r}),a.events.emit("calls",r),this.client.options?.autoRejectCall&&await e.rejectCall(r.callId,r.callerId));}});}async parse(e){let t=a.get("socket"),s={};return s.callId=e.id,s.callerId=jidNormalizedUser(e.from),s.callerName=await this.client.getRoomName(s.callerId),s.roomId=jidNormalizedUser(e.chatId),s.roomName=E(t?.user?.name||t?.user?.verifiedName),s.date=e.date,s.offline=e.offline,s.status=e.status,s.isVideo=!!e.isVideo,s.isGroup=!!e.isGroup,this.client.logs.call(s),s}};var ce={version:"1.1.40-tx.9",author:"zaadevofc"};var yt=o=>{is.generate(o,{small:true},e=>{console.log(e);});},ht=async()=>{console.clear(),a.spinner.start(" Checking for updates...");let o=await Ye(),e=ce.version===o;a.spinner.stop();let t="Zaileys",s=`
|
|
3
|
+
by ${ce.author} \xB7 v${ce.version}`,r=`${e?"Already using latest version!":`Update available! (v${o})`}
|
|
4
|
+
`,i=e?"lime":"orange",n=await ts.text(t),c=cristal(n);console.log(c),console.log(v(s,"#383838ff")),console.log(v(r,i));};var le=class{constructor(e){this.client=e;this.initialize();}async initialize(){a.spinner.start(" Initializing connection...");let e=a.get("socket"),t={},s=async()=>{t.status="reload",a.spinner.warn(" Connection lost. Attempting auto-reload..."),await this.client.initialize();},r=async()=>{await delay(3e3),a.spinner.warn(" Invalid session. Attempting auto cleaning creds..."),await delay(3e3),await Xe(this.client.options.session),await s();};if(this.client.options.authType==="pairing"&&this.client.options.phoneNumber&&!e.authState.creds.registered){a.spinner.update(" Generating pairing code..."),await delay(3500);try{t.authTimeout=Date.now()+6e4;let i=new Date(t.authTimeout).toLocaleTimeString(),n=await e.requestPairingCode(this.client.options.phoneNumber.toString());a.spinner.warn(` Pairing expired at ${cristal(i)}`),a.spinner.warn(` Pairing code: ${n}`),t.code=n;}catch{await r();}}e.ev.on("connection.update",async i=>{let{connection:n,lastDisconnect:c,qr:p}=i;if(t.status=n||"connecting",t.authType=this.client.options.authType,a.spinner.update(" Connection status: "+cristal(t.status)),this.client.options.authType==="qr"&&p){t.authTimeout=Date.now()+6e4;let l=new Date(t.authTimeout).toLocaleTimeString();a.spinner.warn(" Please scan the QR code..."),a.spinner.warn(` Qr code expired at ${cristal(l)}`),yt(p),t.qr=p;return}if(n==="close"){let l=y(c?.error)?.output?.statusCode,k=c?.error?.message||"",x=typeof l=="number"&&l!==DisconnectReason.loggedOut;a.spinner.error(`[${l} - Closed] ${k}`),(l===401||l===405||l===500)&&(a.spinner.error(" Invalid session, please delete manually!"),a.spinner.error(` Session "${this.client.options.session}" has not valid, please delete it!
|
|
5
|
+
`),await r()),x&&await s();}if(n==="open")if(e.user?.id){let l=jidNormalizedUser(e.user.id).split("@")[0],k=e.user.name||e.user.verifiedName;a.spinner.success(` Connected as ${cristal(k||l)}`);}else a.spinner.success(" Connected!");a.events.emit("connection",t);}),e.ev.on("messaging-history.set",({progress:i})=>{t.status="syncing",t.syncProgress=i,a.spinner.start(" Syncing messages history..."),i&&a.spinner.update(` Syncing messages history ${i+"%"}`),i==100&&(a.spinner.success(" Syncing messages history completed!"),t.syncCompleted=true),a.events.emit("connection",t);});}};var kt={text:"text",conversation:"text",imageMessage:"image",contactMessage:"contact",locationMessage:"location",documentMessage:"document",audioMessage:"audio",videoMessage:"video",protocolMessage:"protocol",contactsArrayMessage:"contacts",highlyStructuredMessage:"highlyStructured",sendPaymentMessage:"sendPayment",liveLocationMessage:"location",requestPaymentMessage:"requestPayment",declinePaymentRequestMessage:"declinePaymentRequest",cancelPaymentRequestMessage:"cancelPaymentRequest",templateMessage:"template",stickerMessage:"sticker",groupInviteMessage:"groupInvite",templateButtonReplyMessage:"buttons",productMessage:"product",deviceSentMessage:"deviceSent",listMessage:"lists",viewOnceMessage:"viewOnce",orderMessage:"order",listResponseMessage:"lists",ephemeralMessage:"ephemeral",invoiceMessage:"invoice",buttonsMessage:"buttons",buttonsResponseMessage:"buttons",paymentInviteMessage:"paymentInvite",interactiveMessage:"interactive",reactionMessage:"reaction",stickerSyncRmrMessage:"sticker",questionMessage:"question",nativeFlowResponseMessage:"lists",interactiveResponseMessage:"interactiveResponse",pollCreationMessage:"pollCreation",pollCreationMessageKey:"pollUpdate",pollUpdateMessage:"pollUpdate",keepInChatMessage:"keepInChat",documentWithCaptionMessage:"document",requestPhoneNumberMessage:"requestPhoneNumber",viewOnceMessageV2:"viewOnce",encReactionMessage:"reaction",editedMessage:"text",viewOnceMessageV2Extension:"viewOnce",pollCreationMessageV2:"pollCreation",scheduledCallCreationMessage:"scheduledCallCreation",groupMentionedMessage:"groupMentioned",pinInChatMessage:"pinInChat",pollCreationMessageV3:"pollCreation",scheduledCallEditMessage:"scheduledCallEdit",ptvMessage:"ptv",botInvokeMessage:"botInvoke",callLogMesssage:"callLog",encCommentMessage:"encComment",bcallMessage:"bcall",lottieStickerMessage:"lottieSticker",eventMessage:"event",commentMessage:"comment",newsletterAdminInviteMessage:"text",extendedTextMessageWithParentKey:"text",extendedTextMessage:"text",placeholderMessage:"placeholder",encEventUpdateMessage:"encEventUpdate"},Ue={whatsapp:"0@s.whatsapp.net",meta:"13135550002@s.whatsapp.net",chatgpt:"18002428478@s.whatsapp.net",copilot:"18772241042@s.whatsapp.net",instagram:"447723442971@s.whatsapp.net",tiktok:"6285574670498@s.whatsapp.net"};var ue=class{constructor(e){this.client=e;this.limiter=new RateLimiterMemory({points:this.client.options.limiter?.maxMessages,duration:this.client.options.limiter?.durationMs/1e3});}limiter;async isSpam(e){try{return await this.limiter.consume(e),!1}catch{return true}}};var de=class{constructor(e){this.client=e;this.limiter=new ue(e),this.initialize();}limiter;maxReplies=3;async initialize(){let e=a.get("socket");e.ev.on("messages.upsert",async({messages:t,type:s})=>{if(s==="notify")for(let r of t){let i=await this.parse(r);i&&(this.client.collector.push(i)||(await this.client.middleware.run({messages:i}),await this.client.plugins.execute(this.client,{messages:i}),a.set("message",i),a.events.emit("messages",i)),this.client.options.autoRead&&await e.readMessages([i.message().key]));}});}async parse(e,t){if(e?.category==="peer"||!e?.message||!e?.key?.id||e?.messageStubType||e?.messageStubParameters?.length||e.message?.protocolMessage?.peerDataOperationRequestResponseMessage||e.message?.groupStatusMentionMessage)return;let s=e,r=a.get("socket"),i={},n=G(e.message),c=n.chain.at(-1),p=n.leaf;p?.message&&(n=G(p.message),c=n.chain.at(-1),p=n.leaf),i.uniqueId=null,i.channelId=null,i.chatId=e?.message?.protocolMessage?.key?.id||e?.key?.id||null,i.chatType=kt[c],i.receiverId=jidNormalizedUser(r?.user?.id||""),i.receiverName=E(r?.user?.name||r?.user?.verifiedName),i.roomId=jidNormalizedUser(e?.key?.remoteJid);let l=p?.type===0,k=p?.type===1,x=p?.type===2,X=i.roomId?.includes("@newsletter"),Ae=!!e?.message?.questionMessage,$=e?.key?.fromMe||false;if($&&this.client.options.ignoreMe&&t!=="replied")return;let Ie=p?.key?.id;if(l||k||x){let S=(await this.client.db("messages").get(i.roomId))?.find(B=>B.key.id===Ie);if(!S)return;e=S,n=G(e.message),c=n.chain.at(-1),p=n.leaf;}if(i.roomName=await this.client.getRoomName(i.roomId),i.senderLid=A([e?.key],["remoteJidAlt","participant"])||null,i.senderId=jidNormalizedUser(e?.participant||e?.key?.participant||e?.key?.remoteJid),i.senderName=E(e?.pushName||e?.verifiedBizName),i.senderDevice=getDevice(i.chatId),i.channelId=N([i.roomId,i.senderId]),i.uniqueId=N([i.channelId,i.chatId]),i.timestamp=Number(e?.messageTimestamp)*1e3,X){let C=await r.newsletterMetadata("jid",i.roomId);i.roomName=y(C.thread_metadata.name)?.text,i.senderId=null,i.senderLid=null;}if($&&(i.senderLid=jidNormalizedUser(r.user.lid),i.senderId=i.receiverId,i.senderName=i.receiverName),i.text=p?.text||p?.caption||p?.name||p?.displayName||p?.conversation||p?.contentText||p?.selectedDisplayText||p||null,p?.name=="menu_options"&&(i.text=Ee(p?.paramsJson)?.id),i.text=E(i.text),i.mentions=it(i.text),i.links=tt(i.text||""),i.isBot=i.chatId.startsWith("BAE5")||i.chatId.startsWith("3EB0")||i.chatId.startsWith("Z4D3FC"),i.isFromMe=$,i.isTagMe=i.mentions?.includes(i.receiverId.split("@")[0]),i.isPrefix=i.text?.startsWith(this.client.options?.prefix)||false,i.isSpam=await this.limiter.isSpam(i.channelId),i.isGroup=i.roomId?.includes("@g.us"),i.isNewsletter=X,i.isQuestion=Ae,i.isStory=i.roomId?.includes("@broadcast"),i.isViewOnce=false,i.isEdited=!!te(ee(n),"editedMessage"),i.isDeleted=l,i.isPinned=k,i.isUnPinned=x,i.isBroadcast=!!e?.broadcast,i.isEphemeral=!!te(ee(p?.contextInfo),"ephemeralSettingTimestamp"),i.isForwarded=!!te(ee(p?.contextInfo),"forwardingScore"),i.citation=null,this.client.options.citation){i.citation=i.citation||{};let C=this.client.options.citation;for(let S of Object.keys(C)){let B=C[S];i.citation[S]=async()=>{let U=await B(),Pe=[W(i.roomId),W(i.senderLid),W(i.senderId)];return !!b.intersection(Pe,U).length};}}i.chatType!=="text"&&(i.media={...rt(p),buffer:()=>downloadMediaMessage(e,"buffer",{}),stream:()=>downloadMediaMessage(e,"stream",{})}),i.message=()=>s,i.replied=null;let z=p?.contextInfo?.quotedMessage,j=A([z],["viewOnceMessageV2Extension","viewOnceMessage"]),_=p?.contextInfo?.stanzaId;if(z&&!this.maxReplies){this.maxReplies--;let S=(await this.client.db("messages").get(i.roomId))?.find(U=>U.key.id===_),B={...S,...G(j).leaf};j?(i.replied=await this.parse(B,"replied"),i.replied.isViewOnce=true):i.replied=await this.parse(S,"replied"),this.maxReplies=3;}return this.client.logs.message(i),i}};var fe=class{constructor(e){this.client=e;this.connection=new le(e),this.messages=new de(e),this.calls=new ae(e),this.initialize();}connection;messages;calls;async initialize(){let e=a.get("socket");e.ev.on("groups.update",async([t])=>{let s=await e.groupMetadata(t.id);a.groupCache.set(t.id,s);}),e.ev.on("group-participants.update",async t=>{let s=await e.groupMetadata(t.id);a.groupCache.set(t.id,s);}),e?.ev.on("messaging-history.set",async t=>{let{chats:s,contacts:r,messages:i}=t;for(let n of s)await this.client.db("chats").push(n.id,n);for(let n of r)await this.client.db("contacts").push(n.id,n);for(let n of i){if(!n.message&&!n.key.isViewOnce||n?.category==="peer"||n.message?.protocolMessage||n.message?.groupStatusMentionMessage)return;await this.client.db("messages").push(n.key.remoteJid,n);}}),e?.ev.on("messages.upsert",async({messages:t})=>{for(let s of t){if(!s.message&&!s.key.isViewOnce||s?.category==="peer"||s.message?.protocolMessage||s.message?.groupStatusMentionMessage)return;await this.client.db("messages").push(s.key.remoteJid,s);}}),e?.ev.on("chats.upsert",async t=>{for(let s of t)await this.client.db("chats").push(s.id,s);}),e?.ev.on("contacts.upsert",async t=>{for(let s of t)await this.client.db("contacts").push(s.id,s);});}};var Q=(o,e)=>{let t=o.safeParse(e);if(t.success)return t.data;throw console.error(t.error),"Invalid data"};var ps=u.object({type:u.literal("quick_reply"),text:u.string()}),ls=u.object({type:u.literal("cta_url"),url:u.url(),text:u.string()}),us=u.object({type:u.literal("cta_copy"),copy:u.string(),text:u.string()}),ms=u.object({type:u.literal("cta_call"),text:u.string(),phoneNumber:u.string()}),ds=u.object({type:u.literal("single_select"),text:u.string(),section:u.object({title:u.string(),highlight_label:u.string().optional(),rows:u.object({id:u.string(),title:u.string(),header:u.string().optional(),description:u.string().optional()}).array()}).array()}),fs=u.object({type:u.literal("interactive"),footer:u.string().optional(),data:u.union([ps,ls,us,ms,ds]).array()}),gs=u.object({type:u.literal("simple"),footer:u.string().optional(),data:u.object({id:u.string(),text:u.string()}).array()}),Mt=u.union([gs,fs]);var Y=u.url().or(u.base64()).or(u.instanceof(Buffer)),vt=u.object({text:u.string()}).passthrough(),ys=u.object({image:Y,caption:u.string().optional()}).passthrough(),hs=u.object({audio:Y,caption:u.string().optional(),ptt:u.boolean().optional()}).passthrough(),ks=u.object({video:Y,caption:u.string().optional(),ptv:u.boolean().optional()}).passthrough(),ws=u.object({sticker:Y,caption:u.string().optional()}).passthrough(),Ms=u.object({document:Y,caption:u.string().optional(),fileName:u.string().optional()}).passthrough(),vs=u.object({location:u.object({latitude:u.number(),longitude:u.number(),url:u.url().optional(),title:u.string().optional(),footer:u.string().optional()}).optional()}).passthrough(),bs=u.object({title:u.string().optional(),contacts:u.object({fullname:u.string(),phoneNumber:u.number(),organization:u.string().optional()}).array()}),Ts=u.object({poll:u.object({name:u.string(),answers:u.string().array(),isMultiple:u.boolean().default(false).optional()})}),bt=u.object({replied:u.custom().optional(),isForwardedMany:u.boolean().optional(),isViewOnce:u.boolean().optional(),banner:u.custom().optional(),buttons:Mt.optional()});u.enum(["forward","button","edit","delete"]);var xs=u.union([vt,ys,hs,ks,ws,Ms,vs,bs,Ts]),Tt=u.string().or(u.intersection(xs,bt.omit({buttons:true}))),xt=u.intersection(vt,bt.omit({banner:true}));var ge=class{toNativeSimple(e){return e.map(({id:t,text:s})=>({name:"quick_reply",buttonParamsJson:JSON.stringify({display_text:s,id:t})}))}toNativeInteractive(e){let t={quick_reply:s=>({display_text:s.text,id:s.id}),cta_url:s=>({display_text:s.text,url:s.url,merchant_url:s.url}),cta_copy:s=>({display_text:s.text,id:s.id,copy_code:s.copy}),cta_call:s=>({display_text:s.text,phone_number:s.phoneNumber}),single_select:s=>({title:s.text,sections:s.section})};return e.map(s=>({name:s.type,buttonParamsJson:JSON.stringify(t[s.type](s))}))}build(e){let t=y(e).buttons,s=t?.data||[],i=t?.type=="simple"?this.toNativeSimple(s):this.toNativeInteractive(s);return {body:{text:y(e).text},footer:t.footer?{text:t.footer}:void 0,nativeFlowMessage:{buttons:i}}}async send(e,t,s){let r=a.get("socket"),i=r.authState?.creds?.me?.id||r.user?.id,n=this.build(t),c=generateWAMessageFromContent(e,{interactiveMessage:n},{userJid:i,messageId:generateMessageIDV2(i),...s});return await r.relayMessage(e,c.message,{messageId:c.key.id,...s,additionalNodes:[{tag:"biz",attrs:{},content:[{tag:"interactive",attrs:{type:"native_flow",v:"1"},content:[{tag:"native_flow",attrs:{v:"9",name:"mixed"}}]}]}]}),r.config?.emitOwnEvents&&!isJidGroup(e)&&process.nextTick(()=>r.upsertMessage?.(c,"append")),c}};var ye=class{constructor(e){this.client=e;}async signal(e,t,s,r){s!="delete"&&(s=="button"?t=Q(xt,t):t=Q(Tt,t));let i=a.get("socket"),n={},c={},p=b.isString(t),l=this.client.options?.fakeReply?.provider,k=this.client.options?.autoMentions,x=this.client.options?.autoPresence,X=b.has(t,"replied"),Ae=b.has(t,"banner"),$=b.has(t,"isViewOnce"),Ie=s=="button",z=b.has(t,"image"),j=b.has(t,"video"),_=b.has(t,"audio"),C=b.has(t,"sticker"),S=b.has(t,"document"),B=b.has(t,"location"),U=b.has(t,"contacts"),Pe=b.has(t,"poll"),He=z||j||_||C||S,q=p?t:A([t],["text","caption"]);if(x&&(_?await i.sendPresenceUpdate("recording",e):await i.sendPresenceUpdate("composing",e)),k&&(n={...n,mentions:We(q),contextInfo:{mentionedJid:We(q)}}),X&&(c.quoted=y(t).replied,l&&(c.quoted.key.remoteJid=Ue[l],c.quoted.key.participant=Ue[l])),Ae&&(n={...n,contextInfo:{externalAdReply:y(t).banner}},n.contextInfo.externalAdReply.mediaType=1),$&&(n={...n,viewOnce:y(t)?.isViewOnce}),q&&(n={...n,text:q,caption:q},He&&delete y(n).text),He){let w=A([t],["image","video","audio","sticker","document"]),P=b.isString(w)?{url:w}:w;if(z&&(n={...n,image:P,jpegThumbnail:await De(w)}),j){let R=y(t)?.ptv;n={...n,video:P,ptv:R,jpegThumbnail:await De(w)};}if(_){let R=y(t)?.ptt;n={...n,audio:await nt(w),ptt:R,mimetype:R?"audio/ogg; codecs=opus":"audio/mpeg"};}if(C&&(n={...n,sticker:await ot(w,this.client.options?.sticker)}),S){let R=await at(w);n={...n,fileName:y(t).fileName,...R};}}if(B){let w=y(t).location;n={...n,location:{degreesLatitude:w.latitude,degreesLongitude:w.longitude,url:w.url,address:w.footer,name:w.title}};}if(U){let w=y(t)?.contacts,Ze=w?.contacts.map(P=>{let R=["BEGIN:VCARD","VERSION:3.0",`FN:${P.fullname}`,`ORG:${P.organization||""}`,`TEL;type=CELL;type=VOICE;waid=${P.phoneNumber}:${P.phoneNumber}`,"END:VCARD"].join(`
|
|
6
|
+
`);return {displayName:P.fullname,vcard:R}});n={...n,contacts:{displayName:w?.title,contacts:Ze}};}if(Pe){let w=y(t)?.poll;n={...n,poll:{name:w.name,values:w.answers,selectableCount:w.isMultiple?1:0,toAnnouncementGroup:true}};}return s=="forward"&&(n={...n,contextInfo:{...y(n).contextInfo,isForwarded:true,forwardingScore:y(t).isForwardedMany?9999:1}}),s=="edit"&&(n={...n,edit:r?.key},await i.sendPresenceUpdate("paused",e)),s=="delete"&&(n={...n,delete:r?.key},await i.sendPresenceUpdate("paused",e)),Ie?await new ge().send(e,t,c):await i.sendMessage(e,y(n),c)}async send(e,t){return await this.signal(e,t)}async forward(e,t){return await this.signal(e,t,"forward")}async button(e,t){return await this.signal(e,t,"button")}async edit(e,t){return await this.signal(e.key.remoteJid,t,"edit",e)}async delete(e){return b.isArray(e)?Promise.all(e.map(t=>this.signal(t.key.remoteJid,{},"delete",t))):await this.signal(e.key.remoteJid,{},"delete",e)}async presence(e,t){let s=a.get("socket"),r={typing:"composing",recording:"recording",online:"available",offline:"unavailable",paused:"paused"};return await s.sendPresenceUpdate(r[t],e)}async reaction(e,t){return await a.get("socket").sendMessage(e.key.remoteJid,{react:{text:t,key:e?.key}})}};var qe=class{constructor(e){this.client=e;}async create(e,t){return await a.get("socket").groupCreate(e,t)}async participant(e,t,s){return await a.get("socket").groupParticipantsUpdate(e,t,s)}async profile(e,t,s){let r=a.get("socket"),i=Buffer.isBuffer(t);switch(s){case "subject":if(!i)return await r.groupUpdateSubject(e,t);case "description":if(!i)return await r.groupUpdateDescription(e,t);case "picture":return await r.updateProfilePicture(e,oe(t))}}async setting(e,t){let s=a.get("socket");switch(t){case "open":return await s.groupSettingUpdate(e,"not_announcement");case "close":return await s.groupSettingUpdate(e,"announcement");case "locked":return await s.groupSettingUpdate(e,t);case "unlocked":return await s.groupSettingUpdate(e,t);case "all_member_add":return await s.groupMemberAddMode(e,t);case "admin_add":return await s.groupMemberAddMode(e,t)}}async leave(e){return await a.get("socket").groupLeave(e)}async inviteCode(e,t){let s=a.get("socket");switch(t){case "code":return await s.groupInviteCode(e);case "revoke":return await s.groupRevokeInvite(e);case "accept":return await s.groupAcceptInvite(e);case "info":return await s.groupGetInviteInfo(e)}}async metadata(e){return await a.get("socket").groupMetadata(e)}async requestJoin(e,t,s){let r=a.get("socket");switch(s){case "approve":return await r.groupRequestParticipantsUpdate(e,t,s);case "reject":return await r.groupRequestParticipantsUpdate(e,t,s)}}async requestJoinList(e){return await a.get("socket").groupRequestParticipantsList(e)}async fetchAllGroups(){return await a.get("socket").groupFetchAllParticipating()}async ephemeral(e,t){let s=a.get("socket"),r={off:0,"24h":86400,"7d":604800,"90d":7776e3};return await s.groupToggleEphemeral(e,r[t])}},he=class{constructor(e){this.glient=e;this.group=new qe(e);}group};var Is=z.object({maxMessages:z.number().default(20),durationMs:z.number().default(1e4)}).optional(),Ps=z.record(z.string(),z.function({output:z.promise(z.array(z.number()))})).optional(),Rs=z.object({provider:z.enum(["whatsapp","meta","chatgpt","copilot","instagram","tiktok"]).or(z.number())}).optional(),Es=z.object({packageName:z.string(),authorName:z.string(),quality:z.number()}).optional(),St=z.object({session:z.string().default("zaileys").optional(),prefix:z.string().optional(),ignoreMe:z.boolean().default(true).optional(),showLogs:z.boolean().default(true).optional(),syncFullHistory:z.boolean().default(true).optional(),autoMarkAI:z.boolean().default(true).optional(),autoMentions:z.boolean().default(true).optional(),autoOnline:z.boolean().default(true).optional(),autoRead:z.boolean().default(true).optional(),autoPresence:z.boolean().default(true).optional(),autoRejectCall:z.boolean().default(true).optional(),limiter:Is,citation:Ps,fakeReply:Rs,sticker:Es}),Ws=z.object({authType:z.literal("pairing"),phoneNumber:z.number()}),Ls=z.object({authType:z.literal("qr")}),Ct=z.union([Ws.extend(St.shape),Ls.extend(St.shape)]);z.enum(["connection","messages","calls"]);var ke=class{collect(e,t,s){let r=t.max??1/0;if(r<=0){s([]);return}let i=a.collectors.get(e);i&&(clearTimeout(i.timeoutId),i.callback(i.messages),a.collectors.delete(e));let n=setTimeout(()=>{let c=a.collectors.get(e);c&&(c.callback(c.messages),a.collectors.delete(e));},t.timeout);a.collectors.set(e,{messages:[],max:r,filter:t.filter,callback:s,timeoutId:n});}push(e){let t=a.collectors.get(e.channelId);return !t||t.filter&&!t.filter(e)?false:(t.messages.push(e),t.messages.length>=t.max&&(clearTimeout(t.timeoutId),t.callback(t.messages),a.collectors.delete(e.channelId)),true)}has(e){return a.collectors.has(e)}cancel(e){let t=a.collectors.get(e);return t?(clearTimeout(t.timeoutId),t.callback(t.messages),a.collectors.delete(e),t.messages):[]}};var we=class{constructor(e){this.client=e;this.initialize();}ready=false;getRoomColor(e){return e?.isNewsletter?"blue":e?.isGroup?e?.isGroup?"lime":"#383838ff":"orange"}initialize(){this.client.options.showLogs&&a.events.on("connection",e=>{e?.status==="open"&&(this.ready=true),this.ready&&(console.log(),a.spinner.info("Logs Indicator:"),console.log(v(" \u2022","orange")+" Private Chat"),console.log(v(" \u2022","lime")+" Group Chat"),console.log(v(" \u2022","blue")+" Newsletter Chat"),console.log());});}message(e){if(!this.ready)return;let t=y(this.getRoomColor(e)),s=e?.text?.toLowerCase()?.match("zaileys"),r=v(`[${new Date(e?.timestamp).toTimeString().split(" ")[0]}]`,"#383838ff"),i=v(`${e?.roomName}`,t),n=e?.text?.slice(0,300)||"",c=n?.length>=300?"...":"",p=`${r} \u2192 ${i}
|
|
7
|
+
`;e?.isNewsletter?p+=`${v("[room]","#383838ff")} \u2192 ${v(`${e?.roomName} (${W(e?.roomId)})`,t)}
|
|
8
|
+
`:p+=`${v("[sender]","#383838ff")} \u2192 ${v(`${e?.senderName} (${W(e?.senderId)})`,t)}
|
|
9
|
+
`,p+=`${v(`[${e?.chatType}]`,"#383838ff")} \u2192 ${v(n+c,s?["#ff5f6d","#ffc371"]:"brown")}
|
|
10
|
+
`,p+="\u2014",console.log(p);}call(e){if(!this.ready)return;let t=y(this.getRoomColor(e)),s=v(`[${new Date(e?.date).toTimeString().split(" ")[0]}]`,"#383838ff"),r=v(`${e?.roomName}`,t),i=`${s} \u2192 ${r}
|
|
11
|
+
`;i+=`${v("[caller]","#383838ff")} \u2192 ${v(`${e?.callerName} (${W(e?.callerId)})`,t)}
|
|
12
|
+
`,i+=`${v(`[${e?.status}]`,"#383838ff")} \u2192 ${v(e?.isVideo?"Video Call":"Voice Call","brown")}
|
|
13
|
+
`,i+="\u2014",console.log(i);}};var Me=class{stack=[];use(e){return this.stack.push(e),this}async run(e){let t=-1,s=async r=>{if(r<=t)throw "next() called multiple times";t=r;let i=this.stack[r];if(i)try{await i(e,()=>s(r+1));}catch(n){throw console.error("Middleware error:",n),n}};await s(0);}};var ve=class{plugins=[];pluginsDir;constructor(e=Ne.join(process.cwd(),"plugins")){this.pluginsDir=e;}async load(){if(!be.existsSync(this.pluginsDir))return;let e=be.readdirSync(this.pluginsDir).filter(t=>(t.endsWith(".ts")||t.endsWith(".js"))&&!t.endsWith(".d.ts"));for(let t of e){let s=Ne.join(this.pluginsDir,t);try{let i=(await import(pathToFileURL(s).href)).default;i?.handler&&i?.config&&this.plugins.push(i);}catch{}}}async execute(e,t){let s=t.messages.text||"";for(let r of this.plugins)try{this.match(s,r.config.matcher)&&await r.handler(e,t);}catch{}}match(e,t){return t.some(s=>e===s||e.startsWith(s+" "))}getLoadedPlugins(){return this.plugins}getPluginsInfo(){return this.plugins.map(e=>({matcher:e.config.matcher,metadata:e.config.metadata}))}async reload(){this.plugins=[],await this.load();}},Yn=(o,e)=>({handler:o,config:e});var Te=class{classInjection(e,t){let s=t.length;return new Proxy(e,{get(r,i,n){if(i in r){let c=Reflect.get(r,i,n);return typeof c=="function"?c.bind(r):c}for(let c=0;c<s;c++){let p=t[c];if(i in p){let l=Reflect.get(p,i,n);return typeof l=="function"?l.bind(p):l}}},set(r,i,n,c){if(i in r)return Reflect.set(r,i,n,c);for(let p=0;p<s;p++){let l=t[p];if(i in l)return Reflect.set(l,i,n,c)}return Reflect.set(r,i,n,c)},has(r,i){if(i in e)return true;for(let n=0;n<s;n++)if(i in t[n])return true;return false},ownKeys(){let r=[];for(let i of Reflect.ownKeys(e))r.push(i);for(let i=0;i<s;i++)for(let n of Reflect.ownKeys(t[i]))r.includes(n)||r.push(n);return r},getOwnPropertyDescriptor(r,i){let n=Object.getOwnPropertyDescriptor(e,i);if(n)return n;for(let c=0;c<s;c++)if(n=Object.getOwnPropertyDescriptor(t[c],i),n)return n}})}};var Je=class{constructor(e){this.client=e;}async block(e){return await a.get("socket").updateBlockStatus(e,"block")}async unblock(e){return await a.get("socket").updateBlockStatus(e,"unblock")}async lastSeen(e){return await a.get("socket").updateLastSeenPrivacy(e)}async online(e){return await a.get("socket").updateOnlinePrivacy(e)}async picture(e){return await a.get("socket").updateProfilePicturePrivacy(e)}async status(e){return await a.get("socket").updateStatusPrivacy(e)}async readReceipt(e){return await a.get("socket").updateReadReceiptsPrivacy(e)}async groupsAdd(e){return await a.get("socket").updateGroupsAddPrivacy(e)}async ephemeral(e){let t=a.get("socket"),s={off:0,"24h":86400,"7d":604800,"90d":7776e3};return await t.updateDefaultDisappearingMode(s[e])}async blocklist(){return await a.get("socket").fetchBlocklist()}async getSettings(){return await a.get("socket").fetchPrivacySettings(true)}},xe=class{constructor(e){this.plient=e;this.privacy=new Je(e);}privacy};var Ge=class{constructor(e){this.client=e;}async create(e,t){return await a.get("socket").newsletterCreate(e,t)}async action(e,t){let s=a.get("socket");switch(t){case "follow":return await s.newsletterFollow(e);case "unfollow":return await s.newsletterUnfollow(e);case "mute":return await s.newsletterMute(e);case "unmute":return await s.newsletterUnmute(e);}}async update(e,t,s){let r=a.get("socket"),i=Buffer.isBuffer(t);switch(s){case "name":if(!i)return await r.newsletterUpdateName(e,t);case "description":if(!i)return await r.newsletterUpdateDescription(e,t);case "picture":return await r.newsletterUpdatePicture(e,oe(t))}}async metadata(e,t){return await a.get("socket").newsletterMetadata(t,e)}async subscribers(e){return await a.get("socket").newsletterSubscribers(e)}async reaction(e,t,s){return await a.get("socket").newsletterReactMessage(e,t,s)}async fetchMessages(e,t,s,r){let i=a.get("socket"),n=s.getTime()/1e3,c=r.getTime()/1e3;return await i.newsletterFetchMessages(e,t,n,c)}async adminCount(e){return await a.get("socket").newsletterAdminCount(e)}async changeOwner(e,t){return await a.get("socket").newsletterChangeOwner(e,t)}async demote(e,t){return await a.get("socket").newsletterDemote(e,t)}async delete(e){return await a.get("socket").newsletterDelete(e)}async removePicture(e){return await a.get("socket").newsletterRemovePicture(e)}},Se=class{constructor(e){this.nlient=e;this.newsletter=new Ge(e);}newsletter};var Ke=class{constructor(e){this.client=e;}async create(e,t){return await a.get("socket").communityCreate(e,t)}async createGroup(e,t,s){return await a.get("socket").communityCreateGroup(e,t,s)}async leave(e){return await a.get("socket").communityLeave(e)}async metadata(e){return await a.get("socket").communityMetadata(e)}async update(e,t,s){let r=a.get("socket");switch(t){case "subject":return await r.communityUpdateSubject(e,s);case "description":return await r.communityUpdateDescription(e,s)}}async group(e,t,s){let r=a.get("socket");switch(t){case "link":if(!s)throw "Group JID is required for linking";return await r.communityLinkGroup(e,s);case "unlink":if(!s)throw "Group JID is required for unlinking";return await r.communityUnlinkGroup(e,s);case "linked":return await r.communityFetchLinkedGroups(e)}}async participants(e,t,s,r){let i=a.get("socket");switch(t){case "list":return await i.communityRequestParticipantsList(e);case "request-update":return await i.communityRequestParticipantsUpdate(e,r,y(s));case "update":if(!s||!r)throw "Action and participants are required for update";return await i.communityParticipantsUpdate(e,r,y(s));case "all":return await i.communityFetchAllParticipating()}}async invite(e,t,...s){let r=a.get("socket");switch(t){case "code":return await r.communityInviteCode(e);case "revoke":return await r.communityRevokeInvite(e);case "accept":return await r.communityAcceptInvite(e);case "info":return await r.communityGetInviteInfo(e);case "revokeV4":return await r.communityRevokeInviteV4(e,s[0]);case "acceptV4":return await r.communityAcceptInviteV4(e,s[0])}}async settings(e,t,s){let r=a.get("socket");switch(t){case "ephemeral":return await r.communityToggleEphemeral(e,s);case "update":return await r.communitySettingUpdate(e,s);case "memberAdd":return await r.communityMemberAddMode(e,s);case "approval":return await r.communityJoinApprovalMode(e,s)}}},Ce=class{constructor(e){this.mlient=e;this.community=new Ke(e);}community};var At=class{constructor(e){this.options=e;return this.options=Q(Ct,e),this._ready=this.initialize(),new Te().classInjection(this,[new ye(this),new he(this),new xe(this),new Se(this),new Ce(this)])}listener;_ready;logs;collector=new ke;middleware=new Me;plugins=new ve;async initialize(){await ht(),await ft(this),await this.plugins.load(),this.listener=new fe(this),this.logs=new we(this);}ready(){return this._ready}db(e){return a.lowdb(this.options.session,`stores/${e}.json`)}on(e,t){a.events.on(e,t);}use(e){return this.middleware.use(e),this}async getMessageByChatId(e){let s=(await this.db("messages").all())?.flat()?.filter(r=>typeof r=="object")?.flat()?.find(r=>r?.key?.id===e);return await this.listener.messages.parse(s)}async getRoomName(e){let t=await this.db("chats").get(e),s=await this.db("contacts").get(e),r=A(t,["name","verifiedName"]),i=A(s,["notify","name"]);return E(r||i)||null}};
|
|
14
14
|
/*
|
|
15
15
|
* Copyright (c) 2025 zaadevofc.
|
|
16
16
|
* All rights reserved.
|
|
@@ -18,7 +18,7 @@ by ${ce.author} \xB7 v${ce.version}`,n=`${e?"Already using latest version!":`Upd
|
|
|
18
18
|
* See LICENSE file for details.
|
|
19
19
|
|
|
20
20
|
* Author: zaadevofc
|
|
21
|
-
* Last build time: 12/9/2025
|
|
21
|
+
* Last build time: 12/9/2025 12:00:50 PM
|
|
22
22
|
*
|
|
23
23
|
* Repository: git+https://github.com/zeative/zaileys.git
|
|
24
|
-
*/export{
|
|
24
|
+
*/export{se as AudioProcessor,At as Client,ne as DocumentProcessor,ie as ImageProcessor,ze as Lowdb,Z as MediaProcessor,ve as Plugins,re as StickerProcessor,L as VideoProcessor,W as cleanJid,rt as cleanMediaObject,V as createLowdb,Yn as definePlugins,We as extractJids,tt as extractUrls,te as findGlobalWord,st as findNestedByKeys,N as generateId,G as getDeepContent,Ye as getLatestLibVersion,De as getMediaThumbnail,it as getUsersMentions,wi as getVideoDuration,ki as getVideoThumbnail,nt as getWaAudio,at as getWaDocument,ot as getWaSticker,y as ignoreLint,v as logColor,Xs as modifyFn,E as normalizeText,ni as numbersToJids,A as pickKeysFromArray,Ys as randomize,ft as registerAuthCreds,Xe as removeAuthCreds,Qs as shuffleString,oe as toBuffer,Ee as toJson,ee as toString,mt as useAuthState};
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "zaileys",
|
|
3
|
-
"description": "Zaileys - Simplified WhatsApp Node.js TypeScript/JavaScript API",
|
|
4
|
-
"version": "
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.mjs",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"require": "./dist/index.js",
|
|
13
|
-
"import": "./dist/index.mjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"author": "zaadevofc",
|
|
17
|
-
"repository": {
|
|
18
|
-
"url": "git+https://github.com/zeative/zaileys.git"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"test": "tsx --watch examples/test.ts",
|
|
22
|
-
"build": "tsup",
|
|
23
|
-
"r:patch": "npm run build && npm version patch && npm publish",
|
|
24
|
-
"r:minor": "npm run build && npm version minor && npm publish",
|
|
25
|
-
"r:major": "npm run build && npm version major && npm publish"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/lodash": "^4.17.21",
|
|
29
|
-
"@types/node": "^24.10.1",
|
|
30
|
-
"@types/qrcode-terminal": "^0.12.2",
|
|
31
|
-
"rolldown": "1.0.0-beta.52",
|
|
32
|
-
"rolldown-plugin-dts": "^0.18.1",
|
|
33
|
-
"tsup": "^8.5.1",
|
|
34
|
-
"tsx": "^4.21.0",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
39
|
-
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
40
|
-
"async-mutex": "^0.5.0",
|
|
41
|
-
"audio-decode": "^2.2.3",
|
|
42
|
-
"baileys": "7.0.0-rc.9",
|
|
43
|
-
"figlet": "^1.9.4",
|
|
44
|
-
"file-type": "^21.1.1",
|
|
45
|
-
"fluent-ffmpeg": "^2.1.3",
|
|
46
|
-
"gradient-string": "^3.0.0",
|
|
47
|
-
"lodash": "^4.17.21",
|
|
48
|
-
"lowdb": "^7.0.1",
|
|
49
|
-
"nanospinner": "^1.2.2",
|
|
50
|
-
"node-cache": "^5.1.2",
|
|
51
|
-
"node-webpmux": "^3.2.1",
|
|
52
|
-
"pino": "^10.1.0",
|
|
53
|
-
"qrcode-terminal": "^0.12.0",
|
|
54
|
-
"rate-limiter-flexible": "^9.0.0",
|
|
55
|
-
"sharp": "^0.34.5",
|
|
56
|
-
"thumbsupply": "^0.4.0",
|
|
57
|
-
"zod": "^4.1.13"
|
|
58
|
-
},
|
|
59
|
-
"packageManager": "pnpm@10.24.0",
|
|
60
|
-
"engines": {
|
|
61
|
-
"node": ">=20.0.0"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "zaileys",
|
|
3
|
+
"description": "Zaileys - Simplified WhatsApp Node.js TypeScript/JavaScript API",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"import": "./dist/index.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"author": "zaadevofc",
|
|
17
|
+
"repository": {
|
|
18
|
+
"url": "git+https://github.com/zeative/zaileys.git"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "tsx --watch examples/test.ts",
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"r:patch": "npm run build && npm version patch && npm publish",
|
|
24
|
+
"r:minor": "npm run build && npm version minor && npm publish",
|
|
25
|
+
"r:major": "npm run build && npm version major && npm publish"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/lodash": "^4.17.21",
|
|
29
|
+
"@types/node": "^24.10.1",
|
|
30
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
31
|
+
"rolldown": "1.0.0-beta.52",
|
|
32
|
+
"rolldown-plugin-dts": "^0.18.1",
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"tsx": "^4.21.0",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
39
|
+
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
40
|
+
"async-mutex": "^0.5.0",
|
|
41
|
+
"audio-decode": "^2.2.3",
|
|
42
|
+
"baileys": "7.0.0-rc.9",
|
|
43
|
+
"figlet": "^1.9.4",
|
|
44
|
+
"file-type": "^21.1.1",
|
|
45
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
46
|
+
"gradient-string": "^3.0.0",
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"lowdb": "^7.0.1",
|
|
49
|
+
"nanospinner": "^1.2.2",
|
|
50
|
+
"node-cache": "^5.1.2",
|
|
51
|
+
"node-webpmux": "^3.2.1",
|
|
52
|
+
"pino": "^10.1.0",
|
|
53
|
+
"qrcode-terminal": "^0.12.0",
|
|
54
|
+
"rate-limiter-flexible": "^9.0.0",
|
|
55
|
+
"sharp": "^0.34.5",
|
|
56
|
+
"thumbsupply": "^0.4.0",
|
|
57
|
+
"zod": "^4.1.13"
|
|
58
|
+
},
|
|
59
|
+
"packageManager": "pnpm@10.24.0",
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=20.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|