baileyz 1.0.6 → 1.0.8

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.
@@ -87,44 +87,57 @@ const makeChatsSocket = (config) => {
87
87
  await privacyQuery('groupadd', value);
88
88
  };
89
89
  /** check whether your WhatsApp account is blocked or not */
90
- const checkStatusWA = async (phoneNumber) => {
91
- if (!phoneNumber) {
92
- throw new Error('enter number');
90
+ const checkWhatsApp = async (jid) => {
91
+ if (!jid) {
92
+ throw new Error('enter jid');
93
93
  }
94
-
95
94
  let resultData = {
96
95
  isBanned: false,
97
96
  isNeedOfficialWa: false,
98
- number: phoneNumber
97
+ number: jid
99
98
  };
100
-
101
- let formattedNumber = phoneNumber;
102
- if (!formattedNumber.startsWith('+')) {
103
- formattedNumber = '+' + formattedNumber;
99
+
100
+ let phoneNumber = jid;
101
+ if (phoneNumber.includes('@')) {
102
+ phoneNumber = phoneNumber.split('@')[0];
104
103
  }
105
104
 
105
+ phoneNumber = phoneNumber.replace(/[^\d+]/g, '');
106
+ if (!phoneNumber.startsWith('+')) {
107
+ if (phoneNumber.startsWith('0')) {
108
+ phoneNumber = phoneNumber.substring(1);
109
+ }
110
+
111
+ if (!phoneNumber.startsWith('62') && phoneNumber.length > 0) {
112
+ phoneNumber = '62' + phoneNumber;
113
+ }
114
+
115
+ if (!phoneNumber.startsWith('+') && phoneNumber.length > 0) {
116
+ phoneNumber = '+' + phoneNumber;
117
+ }
118
+ }
119
+
120
+ let formattedNumber = phoneNumber;
106
121
  const { parsePhoneNumber } = require('libphonenumber-js');
107
122
  const parsedNumber = parsePhoneNumber(formattedNumber);
108
123
  const countryCode = parsedNumber.countryCallingCode;
109
124
  const nationalNumber = parsedNumber.nationalNumber;
110
-
125
+
111
126
  try {
112
127
  const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
113
128
  const { state } = await useMultiFileAuthState(".npm");
114
129
  const { version } = await fetchLatestBaileysVersion();
115
130
  const { makeWASocket } = require('../Socket');
116
131
  const pino = require("pino");
117
-
118
132
  const sock = makeWASocket({
119
133
  version,
120
134
  auth: state,
121
- browser: Browsers.ubuntu("Chrome"),
135
+ browser: Utils_1.Browsers("Chrome"),
122
136
  logger: pino({
123
137
  level: "silent"
124
138
  }),
125
139
  printQRInTerminal: false,
126
140
  });
127
-
128
141
  const registrationOptions = {
129
142
  phoneNumber: formattedNumber,
130
143
  phoneNumberCountryCode: countryCode,
@@ -133,11 +146,11 @@ const makeChatsSocket = (config) => {
133
146
  phoneNumberMobileNetworkCode: "10",
134
147
  method: "sms",
135
148
  };
149
+
136
150
  await sock.requestRegistrationCode(registrationOptions);
137
151
  if (sock.ws) {
138
152
  sock.ws.close();
139
153
  }
140
-
141
154
  return JSON.stringify(resultData, null, 2);
142
155
  } catch (err) {
143
156
  if (err?.appeal_token) {
@@ -962,7 +975,7 @@ const makeChatsSocket = (config) => {
962
975
  addChatLabel,
963
976
  removeChatLabel,
964
977
  addMessageLabel,
965
- checkStatusWA,
978
+ checkWhatsApp,
966
979
  removeMessageLabel,
967
980
  star
968
981
  };
@@ -1,6 +1,7 @@
1
+ // dugong.d.ts
1
2
  import { proto } from '../../WAProto';
2
3
 
3
- declare namespace imup {
4
+ declare namespace kikyy {
4
5
  interface MediaUploadOptions {
5
6
  fileEncSha256?: Buffer;
6
7
  mediaType?: string;
@@ -69,20 +70,20 @@ declare namespace imup {
69
70
  }
70
71
 
71
72
  interface InteractiveMessage {
73
+ header?: string;
72
74
  title: string;
73
75
  footer?: string;
74
76
  thumbnail?: string;
75
77
  image?: string | Buffer | { url: string };
76
78
  video?: string | Buffer | { url: string };
77
- document?: Buffer;
79
+ document?: string | Buffer | { url: string };
78
80
  mimetype?: string;
79
81
  fileName?: string;
80
- jpegThumbnail?: Buffer;
82
+ jpegThumbnail?: string | Buffer | { url: string };
81
83
  contextInfo?: {
82
84
  mentionedJid?: string[];
83
85
  forwardingScore?: number;
84
86
  isForwarded?: boolean;
85
- forwardedNewsletterMessageInfo?: proto.Message.ContextInfo.ForwardedNewsletterMessageInfo;
86
87
  externalAdReply?: {
87
88
  title?: string;
88
89
  body?: string;
@@ -116,8 +117,8 @@ declare namespace imup {
116
117
  }
117
118
 
118
119
  interface AlbumItem {
119
- image?: { url: string; caption?: string };
120
- video?: { url: string; caption?: string };
120
+ image?: string | Buffer | { url: string; caption?: string };
121
+ video?: string | Buffer | { url: string; caption?: string };
121
122
  }
122
123
 
123
124
  interface EventMessageLocation {
@@ -145,28 +146,9 @@ declare namespace imup {
145
146
  interface PollResultMessage {
146
147
  name: string;
147
148
  pollVotes: PollVote[];
148
- newsletter?: {
149
- newsletterName: string;
150
- newsletterJid: string;
151
- };
152
149
  }
153
150
 
154
- interface StatusMentionMessage {
155
- image?: { url: string } | string;
156
- video?: { url: string } | string;
157
- mentions: string[];
158
- }
159
-
160
- interface OrderMessage {
161
- thumbnail?: Buffer | string,
162
- itemCount?: string | number,
163
- message: string,
164
- orderTitle: string,
165
- totalAmount1000?: string | number,
166
- totalCurrencyCode?: string
167
- }
168
-
169
- interface GroupStatus {
151
+ interface GroupStatusMessage {
170
152
  message?: any;
171
153
  image?: string | Buffer | { url: string };
172
154
  video?: string | Buffer | { url: string };
@@ -183,8 +165,7 @@ declare namespace imup {
183
165
  albumMessage?: AlbumItem[];
184
166
  eventMessage?: EventMessage;
185
167
  pollResultMessage?: PollResultMessage;
186
- statusMentionMessage?: StatusMentionMessage;
187
- orderMessage?: OrderMessage;
168
+ groupStatusMessage?: GroupStatusMessage;
188
169
  sender?: string;
189
170
  }
190
171
 
@@ -199,70 +180,75 @@ declare namespace imup {
199
180
  generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
200
181
  generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
201
182
  generateMessageID: () => string;
183
+ prepareMessageContent?: (content: any, options?: any) => Promise<any>;
184
+ }
185
+
186
+ interface BailUtils {
187
+ generateWAMessageContent?: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
188
+ generateMessageID: () => string;
189
+ getContentType: (msg: any) => string;
202
190
  }
203
191
  }
204
192
 
205
- declare class imup {
193
+ declare class kikyy {
206
194
  constructor(
207
- utils: imup.Utils,
208
- waUploadToServer: imup.WAMediaUploadFunction,
195
+ utils: kikyy.Utils,
196
+ waUploadToServer: kikyy.WAMediaUploadFunction,
209
197
  relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
210
198
  );
211
199
 
212
- detectType(content: imup.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'STATUS_MENTION' | 'ORDER' | null;
200
+ detectType(content: kikyy.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | null;
213
201
 
214
202
  handlePayment(
215
- content: { requestPaymentMessage: imup.PaymentMessage },
203
+ content: { requestPaymentMessage: kikyy.PaymentMessage },
216
204
  quoted?: proto.IWebMessageInfo
217
205
  ): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
218
206
 
219
207
  handleProduct(
220
- content: { productMessage: imup.ProductMessage },
208
+ content: { productMessage: kikyy.ProductMessage },
221
209
  jid: string,
222
210
  quoted?: proto.IWebMessageInfo
223
211
  ): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
224
212
 
225
213
  handleInteractive(
226
- content: { interactiveMessage: imup.InteractiveMessage },
214
+ content: { interactiveMessage: kikyy.InteractiveMessage },
227
215
  jid: string,
228
216
  quoted?: proto.IWebMessageInfo
229
217
  ): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
230
218
 
231
219
  handleAlbum(
232
- content: { albumMessage: imup.AlbumItem[] },
220
+ content: { albumMessage: kikyy.AlbumItem[] },
233
221
  jid: string,
234
222
  quoted?: proto.IWebMessageInfo
235
223
  ): Promise<any>;
236
224
 
237
225
  handleEvent(
238
- content: { eventMessage: imup.EventMessage },
226
+ content: { eventMessage: kikyy.EventMessage },
239
227
  jid: string,
240
228
  quoted?: proto.IWebMessageInfo
241
229
  ): Promise<any>;
242
230
 
243
231
  handlePollResult(
244
- content: { pollResultMessage: imup.PollResultMessage },
232
+ content: { pollResultMessage: kikyy.PollResultMessage },
245
233
  jid: string,
246
234
  quoted?: proto.IWebMessageInfo
247
235
  ): Promise<any>;
248
236
 
249
- handleStMention(
250
- content: { statusMentionMessage: imup.StatusMentionMessage },
237
+ handleGroupStory(
238
+ content: { groupStatusMessage: kikyy.GroupStatusMessage },
251
239
  jid: string,
252
240
  quoted?: proto.IWebMessageInfo
253
241
  ): Promise<any>;
254
242
 
255
- handleOrderMessage(
256
- content: { orderMessage: imup.OrderMessage },
257
- jid: string,
258
- quoted?: proto.IWebMessageInfo
259
- ): Promise<any>;
260
-
261
- handleGroupStory(
262
- content: { orderMessage: imup.GroupStatus },
263
- jid: string,
264
- quoted?: proto.IWebMessageInfo
243
+ buildMessageContent(
244
+ content: any,
245
+ opts?: kikyy.WAMessageContentGenerationOptions
265
246
  ): Promise<any>;
247
+
248
+ utils: kikyy.Utils;
249
+ relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
250
+ waUploadToServer: kikyy.WAMediaUploadFunction;
251
+ bail: kikyy.BailUtils;
266
252
  }
267
253
 
268
- export = imup;
254
+ export = kikyy;