-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
265 lines (229 loc) · 6.26 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
const qrcode = require('qrcode-terminal');
MessageMedia = require('whatsapp-web.js').MessageMedia;
const path = require('path');
const fs = require('fs');
const { unlink } = require('fs/promises');
var myfile
const directoryPath = path.join(__dirname, 'posts');
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
//listing all files using forEach
files.forEach(function (file,number) {
// console.log(file)
// console.log(number)
// if(number%80==0){
// console.log(number)
// }
});
});
const FileDeleter = async (path) => {
try {
await unlink(path);
console.log(`successfully deleted ${path}`);
} catch (error) {
console.error('there was an error:', error.message);
}
}
const { Client, LocalAuth} = require('whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth(
{
dataPath:'./token'
}
),
puppeteer: {
headless: false,
executablePath: '/usr/bin/google-chrome-stable',
}
});
client.on('qr', qr => {
qrcode.generate(qr, {small: true});
});
const groups=[
// {
// id: '[email protected]',
// name: 'M E M E S T R U A T I O N'
// },
{ id: '[email protected]', name: 'Test' }
// { id: '[email protected]', name: 'DANK AF MEMES' },
]
client.on('ready', async() => {
console.log('Client is ready!');
for (let group of groups) {
client.sendMessage(group['id'], "MEME")
}
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
// files.forEach(function (file) {
// for (let group of groups) {
// console.log('spam started')
// const media = MessageMedia.fromFilePath(`./posts/${file}`);
// client.sendMessage(group['id'], media).then
// (()=>{
// console.log('message sent')
// setTimeout (() => {
// console.log('fil deleting started')
// FileDeleter(`./posts/${file}`)
// console.log('file deleted')
// },300000)
// }
// ).catch((err)=>{console.log(err)})
// }})
});});
client.initialize();
// const name=[
// {
// id: '[email protected]',
// name: 'M E M E S T R U A T I O N'
// },
// // { id: '[email protected]', name: 'DANK AF MEMES' },
// ]
// for (let x of name) {
// console.log(x['id'])
// console.log(x['name'])
// }
// const groupName = 'M E M E S T R U A T I O N'
// const chats = await client.getChats()
// const groups = chats
// .filter(chat => chat.isGroup && chat.name == groupName)
// .map(chat => {
// return {
// id: chat.id._serialized, // ***********-**********@g.us
// name: chat.name // Your Group Name
// }
// })
// console.log(groups)
// client.sendMessage(group['id'], "It's meeeeeeeeeeeeme time")
// //listing all files using forEach
//
// });
// for (let group of groups) {
// // console.log('spam started')
// client.sendMessage(group['id'], "Khatam Tata Bye Bye")
// console.log('completed')
// }
// });
// client.sendMessage(groups[0].id, 'Hello from WhatsApp!');
// client.searchMessages('Hello from WhatsApp! multple', groups[0].id, 1, 1).then((messages) => {
// console.log(messages)
// })
// // send myfile to whatsapp media file
// const media = MessageMedia.fromFilePath(`./posts/${myfile}`);
// client.sendMessage(groups[0].id, media, { caption: 'My Caption' });
// // client.sendMessage(groups[0].id, media);
// fs.readdir(directoryPath, function (err, files) {
// //handling error
// if (err) {
// return console.log('Unable to scan directory: ' + err);
// }
// - 3amjokes
// - ComedyCemetery
// - dadjokes
// - funny
// - jokes
// - 2meirl42meirl4meirl
// - rapedwarflore
// - okretardbuddy
// - absolutelynotme_irl
// - anti_meme
// - blessedimages
// - anime_irl
// - 2meirl4meirl
// - 2meirl42meirl4meirl
// - BikiniBottomTwitter
// - Chinese_Bootleg_Memes
// - chadsriseup
// - coaxedintoasnafu
// - dank_meme
// - dankchristianmemes
// - dankmemes
// - DankMemesFromSite19
// - explainitpeter
// - FlatEarthMemes
// - meirl
// - meme
// - memes
// - metal_me_irl
// - MetalMemes
// - Minimalisticmemes
// - SadMemesForHipTeens
// - simpsonsshitposting
// - smoobypost
// - surrealmemes
// - TooMeIrlForMeIrl
// - wholesomeprequelmemes
// - wholesomememes
// - 4chan
// - AniMemes
// - Animememes
// - MemeEconomy
// - PrequelMemes
// - ProgrammerHumor
// - Whatcouldgowrong
// - ankmemes
// - funny
// - greentext
// - instantregret
// - madlads
// - pewdiepiesubmissions
// - terriblefacebookmemes
// - kidsAreFuckingStupid
// - trippinthroughtime
// - MemeEconomy
// - trippinthroughtime
// - Memes_Of_The_Dank
// - me_irl
// - holup
// - indiandankmeme
// - dankrishu
// subreddit:
// - ComedyCemetery
// - 2meirl42meirl4meirl
// - okretardbuddy
// - anti_meme
// - blessedimages
// - anime_irl
// - 2meirl4meirl
// - 2meirl42meirl4meirl
// - BikiniBottomTwitter
// - dank_meme
// - dankchristianmemes
// - dankmemes
// - explainitpeter
// - meirl
// - meme
// - memes
// - SadMemesForHipTeens
// - simpsonsshitposting
// - surrealmemes
// - TooMeIrlForMeIrl
// - wholesomeprequelmemes
// - wholesomememes
// - 4chan
// - AniMemes
// - Animememes
// - MemeEconomy
// - PrequelMemes
// - ProgrammerHumor
// - Whatcouldgowrong
// - funny
// - greentext
// - instantregret
// - madlads
// - pewdiepiesubmissions
// - terriblefacebookmemes
// - kidsAreFuckingStupid
// - trippinthroughtime
// - MemeEconomy
// - trippinthroughtime
// - Memes_Of_The_Dank
// - me_irl
// - holup
// - indiandankmeme
// - dankrishu