@imjxsx/wapi 1.2.0 → 1.3.1
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 +1 -1
- package/dist/core/bot.d.ts +2 -1
- package/dist/core/bot.d.ts.map +1 -1
- package/dist/core/bot.js +1 -1
- package/dist/core/bot.js.map +2 -2
- package/dist/core/context/context.d.ts.map +1 -1
- package/dist/core/context/context.js +1 -1
- package/dist/core/context/context.js.map +3 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ bot.use(async (ctx, next) => {
|
|
|
68
68
|
bot.logger.info(`New message from '${ctx.from.name}' in '${ctx.chat.name}'`);
|
|
69
69
|
await next();
|
|
70
70
|
});
|
|
71
|
-
// The
|
|
71
|
+
// The default prefixes are '/' and '!'
|
|
72
72
|
bot.command("ping", async (ctx) => {
|
|
73
73
|
await ctx.reply(`> ¡Pong! \`\`\`${bot.ping.toFixed(2)} ms\`\`\``);
|
|
74
74
|
});
|
package/dist/core/bot.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class Bot extends EventEmitter<IBotEventMap> {
|
|
|
13
13
|
status: BotStatus;
|
|
14
14
|
logger: Logger;
|
|
15
15
|
ping: number;
|
|
16
|
+
prefix: string;
|
|
16
17
|
/** @private */
|
|
17
18
|
private middlewares;
|
|
18
19
|
/** @private */
|
|
@@ -21,7 +22,7 @@ export declare class Bot extends EventEmitter<IBotEventMap> {
|
|
|
21
22
|
use(...middlewares: MiddlewareFn[]): void;
|
|
22
23
|
command(name: string, ...middlewares: MiddlewareFn[]): void;
|
|
23
24
|
login(method: "qr" | "otp"): Promise<void>;
|
|
24
|
-
disconnect(reason?:
|
|
25
|
+
disconnect(reason?: Error): Promise<void>;
|
|
25
26
|
logout(reason?: Boom): Promise<void>;
|
|
26
27
|
parseMentions(text: string, server: JidServer): string[];
|
|
27
28
|
parseLinks(text: string): string[];
|
package/dist/core/bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/core/bot.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3I,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAO/C,qBAAa,GAAI,SAAQ,YAAY,CAAC,YAAY,CAAC;IAC1C,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,SAAS,CAAW;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,SAAK;
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/core/bot.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,sBAAsB,EAAE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,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAwB/G,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAYzD,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY7D"}
|
package/dist/core/bot.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import M from"@imjxsx/logger";import A from"node:events";import{Boom as
|
|
1
|
+
import M from"@imjxsx/logger";import A from"node:events";import{Boom as l}from"@hapi/boom";import{makeWASocket as k}from"baileys";import{Context as g}from"./context/context.js";import{decode as y,isGroup as w,isLid as d,isPn as m,normalize as v,toError as o}from"../utils/index.js";import b from"node:os";import{contacts as p,groups as c}from"../cache/index.js";import{Autolinker as B}from"autolinker";import{load as E}from"cheerio";class N extends A{uuid;ws=null;auth;account;status="close";logger;ping=0;prefix="!/";middlewares=[];commands=new Map;constructor(r,e,s,t){super(),this.uuid=r,this.auth=e,this.account=s,this.logger=t??new M({name:`Bot ${this.uuid}`,colorize:process.env.NODE_ENV!=="production",level:process.env.NODE_ENV!=="production"?"TRACE":"INFO"})}use(...r){this.middlewares.push(...r)}command(r,...e){if(!r)throw new Error("The command name must be at least 1 character long.");this.commands.set(r,e)}async login(r){try{const e=await this.auth.init();this.ws=k({auth:e,browser:[b.platform(),"Firefox",b.release()],logger:this.logger.child({name:`WASocket ${this.uuid} `}),qrTimeout:6e4,markOnlineOnConnect:!0,syncFullHistory:!1,shouldSyncHistoryMessage:()=>!1,generateHighQualityLinkPreview:!0,linkPreviewImageThumbnailWidth:1980,shouldIgnoreJid:s=>!w(s)&&!m(s)&&!d(s),cachedGroupMetadata:async s=>c.get(s),version:[2,3e3,1027934701]}),this.ws.ev.on("creds.update",async()=>{try{await this.auth.save()}catch(s){this.emit("error",o(s))}}),this.ws.ev.on("connection.update",async s=>{try{if(s.qr)if(r==="otp"){if(!m(this.account.pn)){await this.disconnect(new l("The OTP code cannot be generated because a number was not provided.",{statusCode:400}));return}const t=await this.ws?.requestPairingCode(y(this.account.pn).jid);if(!t){await this.disconnect(new l(`An OTP code could not be generated for '@${y(this.account.pn).jid}'`,{statusCode:400}));return}this.emit("otp",t)}else this.emit("qr",s.qr);if(s.connection==="close"){this.ws?.ev.removeAllListeners(void 0);const t=new l(s.lastDisconnect?.error).output;switch(this.emit("close",`${t.payload.error} ${t.payload.statusCode}: ${t.payload.message}`),t.payload.statusCode){case 400:case 401:case 403:case 404:case 405:{await this.auth.remove(),this.ws=null,this.removeAllListeners(),this.status="close";break}case 503:{await new Promise(i=>setTimeout(i,3e4)),this.status="reconnecting",await this.login(r);break}case 515:{this.status="reconnecting",await this.login(r);break}default:{if(t.payload.message==="Intentional disconnection."){this.ws=null,this.removeAllListeners(),this.status="close";break}await new Promise(i=>setTimeout(i,5e3)),this.status="reconnecting",await this.login(r)}}return}else if(s.connection==="open"){const t=v(this.ws?.user?.lid),i=v(this.ws?.user?.id),n=this.ws?.user?.verifiedName??this.ws?.user?.name??"";if(!m(i)||!d(t)){await this.disconnect(new l("Restart required.",{statusCode:515}));return}this.account={jid:t,pn:i,name:n},p.set(t,{jid:t,pn:i,name:n}),this.status="open",this.emit("open",this.account);return}}catch(t){this.emit("error",o(t))}}),this.ws.ev.on("messages.upsert",async s=>{try{if(s.type!=="notify"||!s.messages.length)return;for(const t of s.messages){const i=new g(this,t);if(w(i.chat.jid)&&!c.has(i.chat.jid)){const a=await this.groupMetadata(i.chat.jid);a&&c.set(i.chat.jid,a)}d(i.from.jid)&&m(i.from.pn)&&p.set(i.from.jid,{jid:i.from.jid,pn:i.from.pn,name:i.from.name});const n=[...this.middlewares,...this.commands.get(i.commandName)??[]];if(n.length){let a=-1;const u=async h=>{if(h<=a)throw new Error("next() called multiple times.");a=h;const f=n[h];f&&await f(i,async()=>{await u(h+1)})};await u(0)}}}catch(t){this.emit("error",o(t))}}),this.ws.ev.on("contacts.update",s=>{try{for(const t of s){if(!d(t.id)||!p.has(t.id))continue;const i=t.verifiedName??t.notify,n=p.get(t.id);i&&n.name!==i&&(n.name=i)}}catch(t){this.emit("error",o(t))}}),this.ws.ev.on("groups.update",async s=>{try{for(const t of s){if(!w(t.id))continue;c.delete(t.id);const i=await this.groupMetadata(t.id);i&&c.set(t.id,i)}}catch(t){this.emit("error",o(t))}})}catch(e){this.emit("error",o(e))}}async disconnect(r){try{r??=new Error("Intentional disconnection."),this.ws?.end(r)}catch(e){this.emit("error",o(e))}}async logout(r){try{await this.ws?.logout(r?.message)}catch(e){this.emit("error",o(e))}}parseMentions(r,e){try{const s=new Set;for(const t of r.matchAll(/@(\d{7,})/g))t[1]&&s.add(`${t[1]}@${e}`);return Array.from(s.values())}catch(s){return this.emit("error",o(s)),[]}}parseLinks(r){try{const e=new Set,s=B.link(r,{urls:{schemeMatches:!0,ipV4Matches:!1,tldMatches:!0},email:!0,phone:!0,mention:!1,hashtag:!1,stripPrefix:!1,stripTrailingSlash:!1}),t=E(s);return t("a").each((i,n)=>{const a=t(n).attr("href");a&&e.add(a)}),Array.from(e.values())}catch(e){return this.emit("error",o(e)),[]}}async sendMessage(r,e,s){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");const t=performance.now(),i="text"in e&&e.text?e.text:"caption"in e&&e.caption?e.caption:"",n=this.parseMentions(i,s?.addressing==="lid"?"lid":"s.whatsapp.net"),a=await this.ws.sendMessage(r,{...e,mentions:"mentions"in e&&e.mentions?e.mentions.concat(...n):n},s);if(!a)return null;const u=performance.now();return this.ping=u-t,new g(this,a)}catch(t){return this.emit("error",o(t)),null}}async groupMetadata(r){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");return c.get(r)??await this.ws.groupMetadata(r)}catch(e){return this.emit("error",o(e)),null}}async profilePictureUrl(r){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");return await this.ws.profilePictureUrl(r,"image")??"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg"}catch(e){return this.emit("error",o(e)),"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg"}}}export{N as Bot};
|
|
2
2
|
//# sourceMappingURL=bot.js.map
|
package/dist/core/bot.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/core/bot.ts"],
|
|
4
|
-
"sourcesContent": ["import Logger from \"@imjxsx/logger\";\nimport type { UUID } from \"node:crypto\";\nimport EventEmitter from \"node:events\";\nimport { Boom } from \"@hapi/boom\";\nimport type { BotStatus, BotWASocket, IBotAccount, IBotAuth, IBotEventMap, IBotSendMessageOptions, MiddlewareFn } from \"../types/index.js\";\nimport { BaileysEventMap, makeWASocket, type AnyMessageContent, type GroupMetadata, type JidServer } from \"baileys\";\nimport { Context } from \"./context/context.js\";\nimport { decode, isGroup, isLid, isPn, normalize, toError } from \"../utils/index.js\";\nimport os from \"node:os\";\nimport { contacts, groups } from \"../cache/index.js\";\nimport { Autolinker } from \"autolinker\";\nimport { load } from \"cheerio\";\n\nexport class Bot extends EventEmitter<IBotEventMap> {\n public uuid: UUID;\n public ws: BotWASocket | null = null;\n public auth: IBotAuth;\n public account: IBotAccount;\n public status: BotStatus = \"close\";\n public logger: Logger;\n public ping = 0;\n /** @private */\n private middlewares: MiddlewareFn[] = [];\n /** @private */\n private commands = new Map<string, MiddlewareFn[]>();\n constructor(uuid: UUID, auth: IBotAuth, account: IBotAccount, logger?: Logger) {\n super();\n this.uuid = uuid;\n this.auth = auth;\n this.account = account;\n this.logger = logger ?? new Logger({\n name: `Bot ${this.uuid}`,\n colorize: process.env[\"NODE_ENV\"] !== \"production\",\n level: process.env[\"NODE_ENV\"] !== \"production\" ? \"TRACE\" : \"INFO\",\n });\n }\n public use(...middlewares: MiddlewareFn[]): void {\n this.middlewares.push(...middlewares);\n }\n public command(name: string, ...middlewares: MiddlewareFn[]): void {\n if (!name) {\n throw new Error(\"The command name must be at least 1 character long.\");\n }\n this.commands.set(name, middlewares);\n }\n public async login(method: \"qr\" | \"otp\"): Promise<void> {\n try {\n const auth = await this.auth.init();\n this.ws = makeWASocket({\n auth,\n browser: [os.platform(), \"Firefox\", os.release()],\n logger: this.logger.child({ name: `WASocket ${this.uuid} ` }),\n qrTimeout: 60_000,\n markOnlineOnConnect: true,\n syncFullHistory: false,\n shouldSyncHistoryMessage: () => (false),\n generateHighQualityLinkPreview: true,\n linkPreviewImageThumbnailWidth: 1_980,\n shouldIgnoreJid: (jid) => {\n if (!isGroup(jid) && !isPn(jid) && !isLid(jid)) {\n return true;\n }\n return false;\n },\n cachedGroupMetadata: async (jid) => {\n return groups.get(jid);\n },\n version: [2, 3_000, 1_027_934_701],\n });\n this.ws.ev.on(\"creds.update\", async () => {\n try {\n await this.auth.save();\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"connection.update\", async (update) => {\n try {\n if (update.qr) {\n if (method === \"otp\") {\n if (!isPn(this.account.pn)) {\n await this.disconnect(new Boom(\"The OTP code cannot be generated because a number was not provided.\", { statusCode: 400 }));\n return;\n }\n const otp = await this.ws?.requestPairingCode(decode(this.account.pn).jid);\n if (!otp) {\n await this.disconnect(new Boom(`An OTP code could not be generated for '@${decode(this.account.pn).jid}'`, { statusCode: 400 }));\n return;\n }\n this.emit(\"otp\", otp);\n }\n else {\n this.emit(\"qr\", update.qr);\n }\n }\n if (update.connection === \"close\") {\n this.ws?.ev.removeAllListeners(undefined as unknown as keyof BaileysEventMap);\n const output = new Boom(update.lastDisconnect?.error).output;\n this.emit(\"close\", `${output.payload.error} ${output.payload.statusCode}: ${output.payload.message}`);\n switch (output.payload.statusCode) {\n case 405:\n case 404:\n case 403:\n case 401:\n case 400: {\n await this.auth.remove();\n this.ws = null;\n this.removeAllListeners();\n this.status = \"close\";\n break;\n }\n case 503: {\n await new Promise((resolve) => (setTimeout(resolve, 30_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n case 515: {\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n default: {\n await new Promise((resolve) => (setTimeout(resolve, 5_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n }\n }\n return;\n }\n else if (update.connection === \"open\") {\n const jid = normalize(this.ws?.user?.lid);\n const pn = normalize(this.ws?.user?.id);\n const name = this.ws?.user?.verifiedName ?? this.ws?.user?.name ?? \"\";\n if (!isPn(pn) || !isLid(jid)) {\n await this.disconnect(new Boom(\"Restart required.\", { statusCode: 515 }));\n return;\n }\n this.account = { jid, pn, name };\n contacts.set(jid, { jid, pn, name });\n this.status = \"open\";\n this.emit(\"open\", this.account);\n return;\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"messages.upsert\", async (upsert) => {\n try {\n if (upsert.type !== \"notify\" || !upsert.messages.length) {\n return;\n }\n for (const message of upsert.messages) {\n const ctx = new Context(this, message);\n if (isGroup(ctx.chat.jid)) {\n if (!groups.has(ctx.chat.jid)) {\n const metadata = await this.groupMetadata(ctx.chat.jid);\n if (metadata) {\n groups.set(ctx.chat.jid, metadata);\n }\n }\n }\n if (isLid(ctx.from.jid) && isPn(ctx.from.pn)) {\n contacts.set(ctx.from.jid, { jid: ctx.from.jid, pn: ctx.from.pn, name: ctx.from.name });\n }\n const middlewares = [\n ...this.middlewares,\n ...(this.commands.get(ctx.commandName) ?? []),\n ];\n if (middlewares.length) {\n let index = -1;\n const runner = async (i: number): Promise<void> => {\n if (i <= index) {\n throw new Error(\"next() called multiple times.\");\n }\n index = i;\n const fn = middlewares[i];\n if (!fn) {\n return;\n }\n await fn(ctx, async () => {\n await runner(i + 1);\n });\n };\n await runner(0);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"contacts.update\", (updates) => {\n try {\n for (const update of updates) {\n if (!isLid(update.id) || !contacts.has(update.id)) {\n continue;\n }\n const name = update.verifiedName ?? update.notify;\n const contact = contacts.get(update.id)!;\n if (name && contact.name !== name) {\n contact.name = name;\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"groups.update\", async (updates) => {\n try {\n for (const update of updates) {\n if (!isGroup(update.id)) {\n continue;\n }\n groups.delete(update.id);\n const metadata = await this.groupMetadata(update.id);\n if (metadata) {\n groups.set(update.id, metadata);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async disconnect(reason?: Boom): Promise<void> {\n try {\n reason ??= new Boom(\"Intentional disconnection.\", { statusCode: 204 });\n this.ws?.end(reason);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async logout(reason?: Boom): Promise<void> {\n try {\n await this.ws?.logout(reason?.message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public parseMentions(text: string, server: JidServer): string[] {\n try {\n const mentions = new Set<string>();\n for (const match of text.matchAll(/@(\\d{7,})/g)) {\n if (!match[1]) {\n continue;\n }\n mentions.add(`${match[1]}@${server}`);\n }\n return Array.from(mentions.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public parseLinks(text: string): string[] {\n try {\n const links = new Set<string>();\n const html = Autolinker.link(text, {\n urls: {\n schemeMatches: true,\n ipV4Matches: false,\n tldMatches: true,\n },\n email: true,\n phone: true,\n mention: false,\n hashtag: false,\n stripPrefix: false,\n stripTrailingSlash: false,\n });\n const $ = load(html);\n $(\"a\").each((_, el) => {\n const link = $(el).attr(\"href\");\n if (!link) {\n return;\n }\n links.add(link);\n });\n return Array.from(links.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public async sendMessage(jid: string, content: AnyMessageContent, options?: IBotSendMessageOptions): Promise<Context | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n const before = performance.now();\n const text = \"text\" in content && content.text ? content.text : \"caption\" in content && content.caption ? content.caption : \"\";\n const mentions = this.parseMentions(text, options?.addressing === \"lid\" ? \"lid\" : \"s.whatsapp.net\");\n const message = await this.ws.sendMessage(jid, {\n ...content,\n mentions: \"mentions\" in content && content.mentions ? content.mentions.concat(...mentions) : mentions,\n }, options);\n if (!message) {\n return null;\n }\n const after = performance.now();\n this.ping = after - before;\n return new Context(this, message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async groupMetadata(jid: string): Promise<GroupMetadata | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return groups.get(jid) ?? await this.ws.groupMetadata(jid);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async profilePictureUrl(jid: string): Promise<string> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return await this.ws.profilePictureUrl(jid, \"image\") ?? \"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg\";\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return \"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg\";\n }\n }\n}"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAY,iBAEnB,OAAOC,MAAkB,cACzB,OAAS,QAAAC,MAAY,aAErB,OAA0B,gBAAAC,MAAgF,UAC1G,OAAS,WAAAC,MAAe,uBACxB,OAAS,UAAAC,EAAQ,WAAAC,EAAS,SAAAC,EAAO,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,oBACjE,OAAOC,MAAQ,UACf,OAAS,YAAAC,EAAU,UAAAC,MAAc,oBACjC,OAAS,cAAAC,MAAkB,aAC3B,OAAS,QAAAC,MAAY,UAEd,MAAMC,UAAYf,CAA2B,CAC3C,KACA,GAAyB,KACzB,KACA,QACA,OAAoB,QACpB,OACA,KAAO,
|
|
4
|
+
"sourcesContent": ["import Logger from \"@imjxsx/logger\";\nimport type { UUID } from \"node:crypto\";\nimport EventEmitter from \"node:events\";\nimport { Boom } from \"@hapi/boom\";\nimport type { BotStatus, BotWASocket, IBotAccount, IBotAuth, IBotEventMap, IBotSendMessageOptions, MiddlewareFn } from \"../types/index.js\";\nimport { BaileysEventMap, makeWASocket, type AnyMessageContent, type GroupMetadata, type JidServer } from \"baileys\";\nimport { Context } from \"./context/context.js\";\nimport { decode, isGroup, isLid, isPn, normalize, toError } from \"../utils/index.js\";\nimport os from \"node:os\";\nimport { contacts, groups } from \"../cache/index.js\";\nimport { Autolinker } from \"autolinker\";\nimport { load } from \"cheerio\";\n\nexport class Bot extends EventEmitter<IBotEventMap> {\n public uuid: UUID;\n public ws: BotWASocket | null = null;\n public auth: IBotAuth;\n public account: IBotAccount;\n public status: BotStatus = \"close\";\n public logger: Logger;\n public ping = 0;\n public prefix = \"!/\";\n /** @private */\n private middlewares: MiddlewareFn[] = [];\n /** @private */\n private commands = new Map<string, MiddlewareFn[]>();\n constructor(uuid: UUID, auth: IBotAuth, account: IBotAccount, logger?: Logger) {\n super();\n this.uuid = uuid;\n this.auth = auth;\n this.account = account;\n this.logger = logger ?? new Logger({\n name: `Bot ${this.uuid}`,\n colorize: process.env[\"NODE_ENV\"] !== \"production\",\n level: process.env[\"NODE_ENV\"] !== \"production\" ? \"TRACE\" : \"INFO\",\n });\n }\n public use(...middlewares: MiddlewareFn[]): void {\n this.middlewares.push(...middlewares);\n }\n public command(name: string, ...middlewares: MiddlewareFn[]): void {\n if (!name) {\n throw new Error(\"The command name must be at least 1 character long.\");\n }\n this.commands.set(name, middlewares);\n }\n public async login(method: \"qr\" | \"otp\"): Promise<void> {\n try {\n const auth = await this.auth.init();\n this.ws = makeWASocket({\n auth,\n browser: [os.platform(), \"Firefox\", os.release()],\n logger: this.logger.child({ name: `WASocket ${this.uuid} ` }),\n qrTimeout: 60_000,\n markOnlineOnConnect: true,\n syncFullHistory: false,\n shouldSyncHistoryMessage: () => (false),\n generateHighQualityLinkPreview: true,\n linkPreviewImageThumbnailWidth: 1_980,\n shouldIgnoreJid: (jid) => {\n if (!isGroup(jid) && !isPn(jid) && !isLid(jid)) {\n return true;\n }\n return false;\n },\n cachedGroupMetadata: async (jid) => {\n return groups.get(jid);\n },\n version: [2, 3_000, 1_027_934_701],\n });\n this.ws.ev.on(\"creds.update\", async () => {\n try {\n await this.auth.save();\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"connection.update\", async (update) => {\n try {\n if (update.qr) {\n if (method === \"otp\") {\n if (!isPn(this.account.pn)) {\n await this.disconnect(new Boom(\"The OTP code cannot be generated because a number was not provided.\", { statusCode: 400 }));\n return;\n }\n const otp = await this.ws?.requestPairingCode(decode(this.account.pn).jid);\n if (!otp) {\n await this.disconnect(new Boom(`An OTP code could not be generated for '@${decode(this.account.pn).jid}'`, { statusCode: 400 }));\n return;\n }\n this.emit(\"otp\", otp);\n }\n else {\n this.emit(\"qr\", update.qr);\n }\n }\n if (update.connection === \"close\") {\n this.ws?.ev.removeAllListeners(undefined as unknown as keyof BaileysEventMap);\n const output = new Boom(update.lastDisconnect?.error).output;\n this.emit(\"close\", `${output.payload.error} ${output.payload.statusCode}: ${output.payload.message}`);\n switch (output.payload.statusCode) {\n case 400:\n case 401:\n case 403:\n case 404:\n case 405: {\n await this.auth.remove();\n this.ws = null;\n this.removeAllListeners();\n this.status = \"close\";\n break;\n }\n case 503: {\n await new Promise((resolve) => (setTimeout(resolve, 30_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n case 515: {\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n default: {\n if (output.payload.message === \"Intentional disconnection.\") {\n this.ws = null;\n this.removeAllListeners();\n this.status = \"close\";\n break;\n }\n await new Promise((resolve) => (setTimeout(resolve, 5_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n }\n }\n return;\n }\n else if (update.connection === \"open\") {\n const jid = normalize(this.ws?.user?.lid);\n const pn = normalize(this.ws?.user?.id);\n const name = this.ws?.user?.verifiedName ?? this.ws?.user?.name ?? \"\";\n if (!isPn(pn) || !isLid(jid)) {\n await this.disconnect(new Boom(\"Restart required.\", { statusCode: 515 }));\n return;\n }\n this.account = { jid, pn, name };\n contacts.set(jid, { jid, pn, name });\n this.status = \"open\";\n this.emit(\"open\", this.account);\n return;\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"messages.upsert\", async (upsert) => {\n try {\n if (upsert.type !== \"notify\" || !upsert.messages.length) {\n return;\n }\n for (const message of upsert.messages) {\n const ctx = new Context(this, message);\n if (isGroup(ctx.chat.jid)) {\n if (!groups.has(ctx.chat.jid)) {\n const metadata = await this.groupMetadata(ctx.chat.jid);\n if (metadata) {\n groups.set(ctx.chat.jid, metadata);\n }\n }\n }\n if (isLid(ctx.from.jid) && isPn(ctx.from.pn)) {\n contacts.set(ctx.from.jid, { jid: ctx.from.jid, pn: ctx.from.pn, name: ctx.from.name });\n }\n const middlewares = [\n ...this.middlewares,\n ...(this.commands.get(ctx.commandName) ?? []),\n ];\n if (middlewares.length) {\n let index = -1;\n const runner = async (i: number): Promise<void> => {\n if (i <= index) {\n throw new Error(\"next() called multiple times.\");\n }\n index = i;\n const fn = middlewares[i];\n if (!fn) {\n return;\n }\n await fn(ctx, async () => {\n await runner(i + 1);\n });\n };\n await runner(0);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"contacts.update\", (updates) => {\n try {\n for (const update of updates) {\n if (!isLid(update.id) || !contacts.has(update.id)) {\n continue;\n }\n const name = update.verifiedName ?? update.notify;\n const contact = contacts.get(update.id)!;\n if (name && contact.name !== name) {\n contact.name = name;\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"groups.update\", async (updates) => {\n try {\n for (const update of updates) {\n if (!isGroup(update.id)) {\n continue;\n }\n groups.delete(update.id);\n const metadata = await this.groupMetadata(update.id);\n if (metadata) {\n groups.set(update.id, metadata);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async disconnect(reason?: Error): Promise<void> {\n try {\n reason ??= new Error(\"Intentional disconnection.\");\n this.ws?.end(reason);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async logout(reason?: Boom): Promise<void> {\n try {\n await this.ws?.logout(reason?.message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public parseMentions(text: string, server: JidServer): string[] {\n try {\n const mentions = new Set<string>();\n for (const match of text.matchAll(/@(\\d{7,})/g)) {\n if (!match[1]) {\n continue;\n }\n mentions.add(`${match[1]}@${server}`);\n }\n return Array.from(mentions.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public parseLinks(text: string): string[] {\n try {\n const links = new Set<string>();\n const html = Autolinker.link(text, {\n urls: {\n schemeMatches: true,\n ipV4Matches: false,\n tldMatches: true,\n },\n email: true,\n phone: true,\n mention: false,\n hashtag: false,\n stripPrefix: false,\n stripTrailingSlash: false,\n });\n const $ = load(html);\n $(\"a\").each((_, el) => {\n const link = $(el).attr(\"href\");\n if (!link) {\n return;\n }\n links.add(link);\n });\n return Array.from(links.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public async sendMessage(jid: string, content: AnyMessageContent, options?: IBotSendMessageOptions): Promise<Context | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n const before = performance.now();\n const text = \"text\" in content && content.text ? content.text : \"caption\" in content && content.caption ? content.caption : \"\";\n const mentions = this.parseMentions(text, options?.addressing === \"lid\" ? \"lid\" : \"s.whatsapp.net\");\n const message = await this.ws.sendMessage(jid, {\n ...content,\n mentions: \"mentions\" in content && content.mentions ? content.mentions.concat(...mentions) : mentions,\n }, options);\n if (!message) {\n return null;\n }\n const after = performance.now();\n this.ping = after - before;\n return new Context(this, message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async groupMetadata(jid: string): Promise<GroupMetadata | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return groups.get(jid) ?? await this.ws.groupMetadata(jid);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async profilePictureUrl(jid: string): Promise<string> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return await this.ws.profilePictureUrl(jid, \"image\") ?? \"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg\";\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return \"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg\";\n }\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAY,iBAEnB,OAAOC,MAAkB,cACzB,OAAS,QAAAC,MAAY,aAErB,OAA0B,gBAAAC,MAAgF,UAC1G,OAAS,WAAAC,MAAe,uBACxB,OAAS,UAAAC,EAAQ,WAAAC,EAAS,SAAAC,EAAO,QAAAC,EAAM,aAAAC,EAAW,WAAAC,MAAe,oBACjE,OAAOC,MAAQ,UACf,OAAS,YAAAC,EAAU,UAAAC,MAAc,oBACjC,OAAS,cAAAC,MAAkB,aAC3B,OAAS,QAAAC,MAAY,UAEd,MAAMC,UAAYf,CAA2B,CAC3C,KACA,GAAyB,KACzB,KACA,QACA,OAAoB,QACpB,OACA,KAAO,EACP,OAAS,KAER,YAA8B,CAAC,EAE/B,SAAW,IAAI,IACvB,YAAYgB,EAAYC,EAAgBC,EAAsBC,EAAiB,CAC7E,MAAM,EACN,KAAK,KAAOH,EACZ,KAAK,KAAOC,EACZ,KAAK,QAAUC,EACf,KAAK,OAASC,GAAU,IAAIpB,EAAO,CACjC,KAAM,OAAO,KAAK,I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ize", "toError", "os", "contacts", "groups", "Autolinker", "load", "Bot", "uuid", "auth", "account", "logger", "middlewares", "name", "method", "jid", "e", "update", "otp", "output", "resolve", "pn", "upsert", "message", "ctx", "metadata", "index", "runner", "i", "fn", "updates", "contact", "reason", "text", "server", "mentions", "match", "links", "html", "$", "_", "el", "link", "content", "options", "before", "after"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/context/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEpI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,OAAQ,SAAQ,OAAO;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,SAAM;IAChB,WAAW,SAAM;IACjB,IAAI,EAAE,MAAM,EAAE,CAAM;gBACf,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/context/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEpI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,OAAQ,SAAQ,OAAO;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,SAAM;IAChB,WAAW,SAAM;IACjB,IAAI,EAAE,MAAM,EAAE,CAAM;gBACf,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS;IAa3B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB5E,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBpC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAGzC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{downloadMediaMessage as
|
|
1
|
+
import{downloadMediaMessage as h}from"baileys";import{isBuffer as o,isLink as n,toString as a}from"../../utils/index.js";import{Message as d}from"./message.js";class g extends d{bot;prefixUsed="";commandName="";args=[];constructor(e,s){if(super(e,s),this.bot=e,this.text){const t=new RegExp(`^\\s*([${this.bot.prefix}])\\s*([a-zA-Z0-9_$>?-]+)(?:\\s+(.+))?`,"i"),i=(this.text.match(t)??[]).filter(Boolean).map(r=>r.trim());i.length&&(this.prefixUsed=i[1]??"",this.commandName=(i[2]??"").toLowerCase(),this.args=(i[3]??"").split(/\s+/).filter(Boolean).map(r=>r.trim()))}}async reply(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");const t=await this.bot.sendMessage(this.chat.jid,{text:a(e),...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!t)throw new Error("The message could not be sent.");return t}async replyWithImage(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(n(e))t={url:e};else throw new Error("Image type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{image:t,mimetype:"image/jpeg",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithVideo(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(n(e))t={url:e};else throw new Error("Video type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{video:t,mimetype:"video/mp4",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithAudio(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(n(e))t={url:e};else throw new Error("Video type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{audio:t,mimetype:"audio/mpeg",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithSticker(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");if(!o(e))throw new Error("Image type not supported.");const t=await this.bot.sendMessage(this.chat.jid,{sticker:e,mimetype:"image/webp",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!t)throw new Error("The message could not be sent.");return t}async del(){if(!this.chat.jid)throw new Error("Unknown chat.");await this.bot.sendMessage(this.chat.jid,{delete:this.message.key})}async edit(e){if(!this.chat.jid)throw new Error("Unknown chat.");if(!this.message.key.fromMe)throw new Error(`The '${this.id}' message cannot be edited because it was not sent by the client.`);const s=await this.bot.sendMessage(this.chat.jid,{edit:this.message.key,text:a(e)},{addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!s)throw new Error("The message could not be sent.");return s}async download(){return await h(this.message,"buffer",{})}}export{g as Context};
|
|
2
2
|
//# sourceMappingURL=context.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/context/context.ts"],
|
|
4
|
-
"sourcesContent": ["import { downloadMediaMessage, type WAMediaUpload, type WAMessage } from \"baileys\";\nimport type { IReplyOptions, IReplyWithAudioOptions, IReplyWithImageOptions, IReplyWithVideoOptions } from \"../../types/context.js\";\nimport { isBuffer, isLink, toString } from \"../../utils/index.js\";\nimport { Message } from \"./message.js\";\nimport type { Bot } from \"../bot.js\";\n\nexport class Context extends Message {\n public bot: Bot;\n public prefixUsed = \"\";\n public commandName = \"\";\n public args: string[] = [];\n constructor(bot: Bot, message: WAMessage) {\n super(bot, message);\n this.bot = bot;\n if (this.text) {\n const
|
|
5
|
-
"mappings": "AAAA,OAAS,wBAAAA,MAAgE,UAEzE,OAAS,YAAAC,EAAU,UAAAC,EAAQ,YAAAC,MAAgB,uBAC3C,OAAS,WAAAC,MAAe,eAGjB,MAAMC,UAAgBD,CAAQ,CAC5B,IACA,WAAa,GACb,YAAc,GACd,KAAiB,CAAC,EACzB,YAAYE,EAAUC,EAAoB,CAGxC,GAFA,MAAMD,EAAKC,CAAO,EAClB,KAAK,IAAMD,EACP,KAAK,KAAM,CACb,MAAME,GAAS,KAAK,KAAK,
|
|
6
|
-
"names": ["downloadMediaMessage", "isBuffer", "isLink", "toString", "Message", "Context", "bot", "message", "match", "v", "text", "options", "context", "image", "media", "video", "sticker"]
|
|
4
|
+
"sourcesContent": ["import { downloadMediaMessage, type WAMediaUpload, type WAMessage } from \"baileys\";\nimport type { IReplyOptions, IReplyWithAudioOptions, IReplyWithImageOptions, IReplyWithVideoOptions } from \"../../types/context.js\";\nimport { isBuffer, isLink, toString } from \"../../utils/index.js\";\nimport { Message } from \"./message.js\";\nimport type { Bot } from \"../bot.js\";\n\nexport class Context extends Message {\n public bot: Bot;\n public prefixUsed = \"\";\n public commandName = \"\";\n public args: string[] = [];\n constructor(bot: Bot, message: WAMessage) {\n super(bot, message);\n this.bot = bot;\n if (this.text) {\n const regexp = new RegExp(`^\\\\s*([${this.bot.prefix}])\\\\s*([a-zA-Z0-9_$>?-]+)(?:\\\\s+(.+))?`, \"i\");\n const match = (this.text.match(regexp) ?? []).filter(Boolean).map((v) => (v.trim()));\n if (match.length) {\n this.prefixUsed = match[1] ?? \"\";\n this.commandName = (match[2] ?? \"\").toLowerCase();\n this.args = (match[3] ?? \"\").split(/\\s+/).filter(Boolean).map((v) => (v.trim()));\n }\n }\n }\n public async reply(text: string, options?: IReplyOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n text: toString(text),\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithImage(image: string | Buffer, options?: IReplyWithImageOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(image)) {\n media = image;\n }\n else if (isLink(image)) {\n media = {\n url: image,\n };\n }\n else {\n throw new Error(\"Image type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n image: media,\n mimetype: \"image/jpeg\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithVideo(video: string | Buffer, options?: IReplyWithVideoOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(video)) {\n media = video;\n }\n else if (isLink(video)) {\n media = {\n url: video,\n };\n }\n else {\n throw new Error(\"Video type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n video: media,\n mimetype: \"video/mp4\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithAudio(video: string | Buffer, options?: IReplyWithAudioOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(video)) {\n media = video;\n }\n else if (isLink(video)) {\n media = {\n url: video,\n };\n }\n else {\n throw new Error(\"Video type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n audio: media,\n mimetype: \"audio/mpeg\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithSticker(sticker: Buffer, options?: IReplyOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n if (!isBuffer(sticker)) {\n throw new Error(\"Image type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n sticker,\n mimetype: \"image/webp\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async del(): Promise<void> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n await this.bot.sendMessage(this.chat.jid, {\n delete: this.message.key,\n });\n }\n public async edit(text: string): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n if (!this.message.key.fromMe) {\n throw new Error(`The '${this.id}' message cannot be edited because it was not sent by the client.`);\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n edit: this.message.key,\n text: toString(text),\n }, {\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async download(): Promise<Buffer> {\n return await downloadMediaMessage(this.message, \"buffer\", {});\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,wBAAAA,MAAgE,UAEzE,OAAS,YAAAC,EAAU,UAAAC,EAAQ,YAAAC,MAAgB,uBAC3C,OAAS,WAAAC,MAAe,eAGjB,MAAMC,UAAgBD,CAAQ,CAC5B,IACA,WAAa,GACb,YAAc,GACd,KAAiB,CAAC,EACzB,YAAYE,EAAUC,EAAoB,CAGxC,GAFA,MAAMD,EAAKC,CAAO,EAClB,KAAK,IAAMD,EACP,KAAK,KAAM,CACb,MAAME,EAAS,IAAI,OAAO,UAAU,KAAK,IAAI,MAAM,yCAA0C,GAAG,EAC1FC,GAAS,KAAK,KAAK,MAAMD,CAAM,GAAK,CAAC,GAAG,OAAO,OAAO,EAAE,IAAKE,GAAOA,EAAE,KAAK,CAAE,EAC/ED,EAAM,SACR,KAAK,WAAaA,EAAM,CAAC,GAAK,GAC9B,KAAK,aAAeA,EAAM,CAAC,GAAK,IAAI,YAAY,EAChD,KAAK,MAAQA,EAAM,CAAC,GAAK,IAAI,MAAM,KAAK,EAAE,OAAO,OAAO,EAAE,IAAKC,GAAOA,EAAE,KAAK,CAAE,EAEnF,CACF,CACA,MAAa,MAAMC,EAAcC,EAA2C,CAC1E,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,MAAMC,EAAU,MAAM,KAAK,IAAI,YAAY,KAAK,KAAK,IAAK,CACxD,KAAMV,EAASQ,CAAI,EACnB,GAAGC,CACL,EAAG,CACD,OAAQ,KAAK,QACb,WAAY,KAAK,KAAK,aAAe,MAAQ,MAAQ,IACvD,CAAC,EACD,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,gCAAgC,EAElD,OAAOA,CACT,CACA,MAAa,eAAeC,EAAwBF,EAAoD,CACtG,GAAI,CAAC,KAAK,KAAK,IACb,MAAM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
+
"names": ["downloadMediaMessage", "isBuffer", "isLink", "toString", "Message", "Context", "bot", "message", "regexp", "match", "v", "text", "options", "context", "image", "media", "video", "sticker"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Context } from "./core/context/context.js";
|
|
1
2
|
export * from "./cache/index.js";
|
|
2
3
|
export * from "./core/auth/index.js";
|
|
3
4
|
export * from "./core/bot.js";
|
|
4
5
|
export * from "./types/index.js";
|
|
5
6
|
export * from "./utils/jid.js";
|
|
6
7
|
export * from "./utils/message-builder.js";
|
|
8
|
+
export interface IContext extends InstanceType<typeof Context> {
|
|
9
|
+
}
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,MAAM,WAAW,QAAS,SAAQ,YAAY,CAAC,OAAO,OAAO,CAAC;CAAI"}
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Context } from \"./core/context/context.js\";\n\nexport * from \"./cache/index.js\";\nexport * from \"./core/auth/index.js\";\nexport * from \"./core/bot.js\";\nexport * from \"./types/index.js\";\nexport * from \"./utils/jid.js\";\nexport * from \"./utils/message-builder.js\";\nexport interface IContext extends InstanceType<typeof Context> { }"],
|
|
5
|
+
"mappings": "AAEA,WAAc,mBACd,WAAc,uBACd,WAAc,gBACd,WAAc,mBACd,WAAc,iBACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imjxsx/wapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Framework for developing bots for the WhatsApp application: fast, secure, and elegant, powered by Baileys and developed 100% in TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,13 +16,6 @@
|
|
|
16
16
|
"./dist",
|
|
17
17
|
"./README.md"
|
|
18
18
|
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "node ./example/index",
|
|
21
|
-
"build": "pnpm run build:types && pnpm run build:js",
|
|
22
|
-
"build:types": "tsc --emitDeclarationOnly",
|
|
23
|
-
"build:js": "esbuild './src/**/*.ts' --outbase=src --outdir=dist --format=esm --platform=node --target=es2022 --sourcemap --minify --packages=external",
|
|
24
|
-
"prepare": "pnpm run build"
|
|
25
|
-
},
|
|
26
19
|
"keywords": [
|
|
27
20
|
"bot",
|
|
28
21
|
"whatsapp",
|
|
@@ -39,7 +32,6 @@
|
|
|
39
32
|
"url": "https://github.com/imjxsx/wapi/issues"
|
|
40
33
|
},
|
|
41
34
|
"homepage": "https://github.com/imjxsx/wapi#readme",
|
|
42
|
-
"packageManager": "pnpm@10.20.0",
|
|
43
35
|
"dependencies": {
|
|
44
36
|
"@hapi/boom": "10.0.1",
|
|
45
37
|
"@imjxsx/logger": "1.1.1",
|
|
@@ -60,5 +52,11 @@
|
|
|
60
52
|
},
|
|
61
53
|
"engines": {
|
|
62
54
|
"node": ">=20.0.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"dev": "node ./example/index",
|
|
58
|
+
"build": "pnpm run build:types && pnpm run build:js",
|
|
59
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
60
|
+
"build:js": "esbuild './src/**/*.ts' --outbase=src --outdir=dist --format=esm --platform=node --target=es2022 --sourcemap --minify --packages=external"
|
|
63
61
|
}
|
|
64
62
|
}
|