zaileys 1.1.32 → 1.1.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zaileys",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "Zaileys - Simplified WhatsApp Node.js API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,25 +0,0 @@
1
- import { Client } from "../src";
2
- // import { Client } from "zaileys";
3
-
4
- const wa = new Client({
5
- authType: "qr", // has issue with pairing code, just use qr only,
6
- citation: {
7
- authors: () => [62858000000, 628580000],
8
- otherNumbers: () => [62830000000, 628300000],
9
- premiumUsers: async () => {
10
- const numbers = await fetch("https://api.npoint.io/cd9d2eeb80838a6c86bb").then((x) => x.json()).catch(() => []);
11
- return numbers;
12
- },
13
- },
14
- });
15
-
16
- wa.on("messages", (ctx) => {
17
- const { citation, roomId } = ctx;
18
-
19
- // from 'author' to 'isAuthors'
20
- console.log(citation?.isAuthors); // boolean
21
-
22
- if (citation?.isPremiumUsers) {
23
- wa.text("Hello premium users!", { roomId });
24
- }
25
- });
@@ -1,23 +0,0 @@
1
- import { Client } from "../src";
2
- // import { Client } from "zaileys";
3
-
4
- const wa = new Client({
5
- authType: "qr", // has issue with pairing code, just use qr only
6
-
7
- // max 10 messages on 10 seconds
8
- limiter: {
9
- durationMs: 10000,
10
- maxMessages: 5,
11
- },
12
- });
13
-
14
- wa.on("messages", (ctx) => {
15
- const { isSpam, roomId } = ctx;
16
-
17
- if (isSpam) {
18
- wa.text("You're spamming!!", { roomId });
19
- return;
20
- }
21
-
22
- wa.text("Hello!", { roomId });
23
- });
package/examples/llms.ts DELETED
@@ -1,37 +0,0 @@
1
- import Groq from "groq-sdk";
2
-
3
- import { Client } from "../src";
4
- // import { Client } from "zaileys";
5
-
6
- const groq = new Groq({ apiKey: "YOUR_GROQ_APIKEY" });
7
-
8
- const wa = new Client({
9
- authType: "qr", // has issue with pairing code, just use qr only
10
- loadLLMSchemas: true, // this option must be activated!
11
- });
12
-
13
- wa.on("messages", async (ctx) => {
14
- const { channelId, uniqueId, roomId, text } = ctx;
15
-
16
- if (text == "clear") {
17
- await wa.llms.clearCompletions(channelId);
18
- await wa.text("History clear!", { roomId });
19
- return;
20
- }
21
-
22
- const histories = await wa.llms.getCompletions(channelId);
23
- const model = await groq.chat.completions.create({
24
- messages: [
25
- { role: "system", content: "You are 'Zaileys AI' a helpful assistant speak indonesian." },
26
- ...(histories.map((x) => ({ role: x.role, content: x.content })) as never),
27
- { role: "user", content: text || "" },
28
- ],
29
- model: "llama-3.3-70b-versatile",
30
- });
31
-
32
- const output = model.choices[0]?.message?.content || "";
33
- const ai = await wa.text(output, { roomId });
34
-
35
- await wa.llms.addCompletion({ channelId, uniqueId, role: "user", content: text || "" });
36
- await wa.llms.addCompletion({ channelId, uniqueId: ai?.uniqueId || "", role: "assistant", content: output });
37
- });
@@ -1,16 +0,0 @@
1
- import { Client } from "../src";
2
- // import { Client } from "zaileys";
3
-
4
- const wa = new Client({
5
- authType: "qr", // has issue with pairing code, just use qr only
6
- });
7
-
8
- wa.on("messages", (ctx) => {
9
- wa.text("Hello!", { roomId: ctx.roomId });
10
- });
11
-
12
- wa.on("calls", (ctx) => {
13
- if (ctx.status == "terminate") {
14
- wa.text("Why call me!?", { roomId: ctx.roomId });
15
- }
16
- });
@@ -1,36 +0,0 @@
1
- import { createPartFromUri, createUserContent, GoogleGenAI } from "@google/genai";
2
-
3
- import { Client } from "../src";
4
- // import { Client } from "zaileys";
5
-
6
- const agent = new GoogleGenAI({ apiKey: "YOUR_GEMINI_APIKEY" });
7
-
8
- const wa = new Client({
9
- authType: "qr", // has issue with pairing code, just use qr only
10
- });
11
-
12
- wa.on("messages", async (ctx) => {
13
- if (ctx.chatType != "audio") return;
14
-
15
- const buffer = await ctx.media?.buffer();
16
- const stream = new File([buffer || ""], "voice.ogg", { type: "audio/ogg" });
17
-
18
- const uploaded = await agent.files.upload({
19
- file: stream,
20
- config: { mimeType: "audio/ogg" },
21
- });
22
-
23
- const speech = await agent.models
24
- .generateContent({
25
- model: "gemini-2.0-flash-001",
26
- contents: createUserContent([
27
- {
28
- text: "Transcribe it internally, but do not output the transcription. Simply respond to the message as if you were replying naturally in a conversation. Be direct, contextual, and human-like—no need to mention the transcription process or analyze the speaker’s intent.",
29
- },
30
- createPartFromUri(uploaded.uri!, uploaded.mimeType!),
31
- ]),
32
- })
33
- .then((x) => x.candidates?.[0].content?.parts?.[0].text || "");
34
-
35
- await wa.text(speech, { roomId: ctx.roomId });
36
- });
@@ -1,37 +0,0 @@
1
- import { Client } from "../src";
2
- // import { Client } from "zaileys";
3
-
4
- const wa = new Client({
5
- authType: "qr", // has issue with pairing code, just use qr only
6
- webhooks: {
7
- url: "https://...", // An event triggers a call to the webhook url
8
- },
9
- });
10
-
11
- /*
12
- ✔ Webhooks Access
13
- - URL : http://xxx.xxx.x.xxx:4135/webhooks
14
- - PORT : 4135
15
- - METHOD: GET, POST
16
-
17
- hit to "URL" with data to be captured by "webhooks" event
18
- example:
19
-
20
- await fetch("http://xxx.xxx.x.xxx:4135/webhooks?test1=hello&test2=world", {
21
- method: "POST", // optional (GET & POST only)
22
- body: JSON.stringify({ testingBody: "OK", yourData: "test1" })
23
- })
24
- */
25
-
26
- wa.on("webhooks", (ctx) => {
27
- // passing search params
28
- console.log(ctx.data.query); // { test1: "hello", test2: "world" }
29
-
30
- // passing body
31
- console.log(ctx.data.json); // { testingBody: "OK", yourData: "test1" }
32
-
33
- // lets explore
34
- console.log(ctx)
35
- console.log(ctx.data.form)
36
- console.log(ctx.data.raw)
37
- });