@neoxr/wb 1.45.65

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Wildan Izzudin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ ## Simplicity WhatsApp Bot (Baileys)
2
+
3
+ > This is a WhatsApp bot module based on Baileys which can be used in a very easy way.
4
+
5
+ ### Example
6
+
7
+ For example of use you can open the [example](https://github.com/neoxr/wb/tree/master/example) folder or here for [example base](https://github.com/neoxr/wbot)
8
+
9
+ <p align="center"><img align="center" width="100%" src="https://telegra.ph/file/9eba13b933e03e2203af0.png" /></p>
10
+
11
+ ### Handling Events
12
+
13
+ There are several events that can be used are as follows :
14
+
15
+ ```Javascript
16
+ client.on('connect', () => console.log)
17
+ client.on('error', error => console.log(error))
18
+ client.on('ready', () => console.log)
19
+ client.on('message', ctx => console.log(ctx))
20
+ client.on('message.delete', ctx => console.log(ctx))
21
+ client.on('group.add', ctx => console.log(ctx))
22
+ client.on('group.remove', ctx => console.log(ctx))
23
+ client.on('group.promote', ctx => console.log(ctx))
24
+ client.on('group.demote', ctx => console.log(ctx))
25
+ client.on('caller', ctx => console.log(ctx))
26
+ client.on('poll', ctx => console.log(ctx))
27
+ client.on('presence.update', ctx => console.log(ctx))
28
+ ```
29
+
30
+ ### Event Message (message)
31
+
32
+ ```Javascript
33
+ {
34
+ m: {
35
+ key: {
36
+ remoteJid: '6285887776722@s.whatsapp.net',
37
+ fromMe: false,
38
+ id: 'A4A5E1FB9C33178CD11673178C46CA1E',
39
+ participant: undefined
40
+ },
41
+ messageTimestamp: 1689557472,
42
+ pushName: 'Wildan Izzudin',
43
+ broadcast: false,
44
+ message: Message {
45
+ extendedTextMessage: [ExtendedTextMessage],
46
+ messageContextInfo: [MessageContextInfo]
47
+ },
48
+ id: 'A4A5E1FB9C33178CD11673178C46CA1E',
49
+ isBot: false,
50
+ chat: '6285887776722@s.whatsapp.net',
51
+ fromMe: false,
52
+ isGroup: false,
53
+ sender: '6285887776722@s.whatsapp.net',
54
+ mtype: 'extendedTextMessage',
55
+ msg: ExtendedTextMessage {
56
+ text: '.menu',
57
+ previewType: 0,
58
+ contextInfo: [ContextInfo],
59
+ inviteLinkGroupTypeV2: 0
60
+ },
61
+ quoted: null,
62
+ mentionedJid: [],
63
+ reply: [Function(anonymous)],
64
+ text: '.menu'
65
+ },
66
+ body: '.menu',
67
+ prefix: '.',
68
+ plugins: [],
69
+ commands: [],
70
+ args: [],
71
+ command: 'menu',
72
+ text: '',
73
+ prefixes: ['.', '#', '!', '/']
74
+ }
75
+ ```
76
+ ### Messaging Function
77
+
78
+ ```Javascript
79
+ // declaration variable sock
80
+ const sock = client.sock
81
+
82
+ // send a text message (auto tagged)
83
+ sock.reply(m.chat, `Test!`, m)
84
+
85
+ // send a react message
86
+ sock.sendReact(m.chat, `💀`, m.key)
87
+
88
+ // send a text message with progress bar
89
+ sock.sendProgress(m.chat, `Test!`, m)
90
+
91
+ // send a ptv message from path, url, or buffer (video duration 10s)
92
+ sock.sendPtv(m.chat, `./media/video/yemete.mp4`)
93
+
94
+ // send a text message with custom thumbnail
95
+ sock.sendMessageModify(m.chat, `Test!`, m, {
96
+ title: '© neoxr-bot',
97
+ largeThumb: true,
98
+ ads: false,
99
+ /* can buffer or url */
100
+ thumbnail: 'https://iili.io/HP3ODj2.jpg',
101
+ link: 'https://chat.whatsapp.com/HYknAquOTrECm9KPJJQO1V'
102
+ })
103
+
104
+ // send a text message with custom thumbnail & fake quoted
105
+ sock.sendMessageModifyV2(m.chat, `Test!`, '© neoxr-bot', {
106
+ title: '© neoxr-bot',
107
+ largeThumb: true,
108
+ ads: false,
109
+ /* can buffer or url */
110
+ thumbnail: 'https://iili.io/HP3ODj2.jpg',
111
+ link: 'https://chat.whatsapp.com/HYknAquOTrECm9KPJJQO1V'
112
+ })
113
+
114
+ // send a text message with fake quoted
115
+ sock.sendMessageVerify(m.chat, `Test!`, '© neoxr-bot')
116
+
117
+ // send a file from path, url, or buffer (auto extension)
118
+ sock.sendFile(m.chat, 'https://iili.io/HP3ODj2.jpg', 'image.jpg', 'Test!', m)
119
+
120
+ // send a document from path, url, or buffer (auto extension)
121
+ sock.sendFile(m.chat, 'https://iili.io/HP3ODj2.jpg', 'image.jpg', 'Test!', m, {
122
+ document: true
123
+ })
124
+
125
+ // send a voicenote from path, url, or buffer
126
+ sock.sendFile(m.chat, './media/audio/ah.mp3', '', '', m, {
127
+ ptt: true
128
+ })
129
+
130
+ // send a audio from path, url, or buffer with thumbnail in audio tag
131
+ sock.sendFile(m.chat, './media/audio/ah.mp3', '', '', m, {
132
+ APIC: < Buffer >
133
+ })
134
+
135
+ // send a sticker message from url or buffer
136
+ sock.sendSticker(m.chat, 'https://iili.io/HP3ODj2.jpg', m, {
137
+ packname: 'Sticker by',
138
+ author: '© neoxr.js'
139
+ })
140
+
141
+ // send polling message
142
+ sock.sendPoll(m.chat, 'Do you like this library ?', {
143
+ options: ['Yes', 'No'],
144
+ multiselect: false
145
+ })
146
+
147
+ // send contact message
148
+ sock.sendContact(m.chat, [{
149
+ name: 'Wildan Izzudin',
150
+ number: '6285887776722',
151
+ about: 'Owner & Creator'
152
+ }], m, {
153
+ org: 'Neoxr Network',
154
+ website: 'https://api.neoxr.my.id',
155
+ email: 'contact@neoxr.my.id'
156
+ })
157
+
158
+ // forward message
159
+ sock.copyNForward(m.chat, m)
160
+
161
+ // send button message (your own risk)
162
+ var buttons = [{
163
+ name: "quick_reply",
164
+ buttonParamsJson: JSON.stringify({
165
+ display_text: "OWNER",
166
+ id: '.owner'
167
+ }),
168
+ }, {
169
+ name: "cta_url",
170
+ buttonParamsJson: JSON.stringify({
171
+ display_text: "Rest API",
172
+ url: "https://api.neoxr.my.id",
173
+ merchant_url: "https://api.neoxr.my.id"
174
+ })
175
+ }, {
176
+ name: "cta_copy",
177
+ buttonParamsJson: JSON.stringify({
178
+ display_text: "Copy",
179
+ copy_code: "123456"
180
+ })
181
+ }, {
182
+ name: "cta_call",
183
+ buttonParamsJson: JSON.stringify({
184
+ display_text: "Call",
185
+ phone_number: "6285887776722"
186
+ })
187
+ }, {
188
+ name: "single_select",
189
+ buttonParamsJson: JSON.stringify({
190
+ title: "Tap!",
191
+ sections: [{
192
+ rows: [{
193
+ title: "Owner",
194
+ description: `X`,
195
+ id: `.owner`
196
+ }, {
197
+ title: "Runtime",
198
+ description: `Y`,
199
+ id: `.run`
200
+ }]
201
+ }]
202
+ })
203
+ }]
204
+
205
+ // button & list
206
+ client.sendIAMessage(m.chat, buttons, m, {
207
+ header: '',
208
+ content: 'Hi!',
209
+ footer: '',
210
+ media: global.db.setting.cover // video or image link
211
+ })
212
+
213
+ // carousel message
214
+ const cards = [{
215
+ header: {
216
+ imageMessage: global.db.setting.cover,
217
+ hasMediaAttachment: true,
218
+ },
219
+ body: {
220
+ text: "P"
221
+ },
222
+ nativeFlowMessage: {
223
+ buttons: [{
224
+ name: "cta_url",
225
+ buttonParamsJson: JSON.stringify({
226
+ display_text: 'Contact Owner',
227
+ url: 'https://api.neoxr.eu',
228
+ webview_presentation: null
229
+ })
230
+ }]
231
+ }
232
+ }, {
233
+ header: {
234
+ imageMessage: global.db.setting.cover,
235
+ hasMediaAttachment: true,
236
+ },
237
+ body: {
238
+ text: "P"
239
+ },
240
+ nativeFlowMessage: {
241
+ buttons: [{
242
+ name: "cta_url",
243
+ buttonParamsJson: JSON.stringify({
244
+ display_text: 'Contact Owner',
245
+ url: 'https://api.neoxr.eu',
246
+ webview_presentation: null
247
+ })
248
+ }]
249
+ }
250
+ }]
251
+
252
+ client.sendCarousel(m.chat, cards, m, {
253
+ content: 'Hi!'
254
+ })
255
+ ```