-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (42 loc) · 1.33 KB
/
Copy pathindex.js
File metadata and controls
55 lines (42 loc) · 1.33 KB
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
const qrcode = require('qrcode-terminal')
const { Client, LocalAuth , Buttons } = require('whatsapp-web.js');
const cron = require('node-cron');
const express = require('express')
const app = express();
const port = 8888;
require('dotenv').config()
const {AI_TEXT_GENERATION} = require('./ai')
const client = new Client(
{
authStrategy: new LocalAuth()
}
);
cron.schedule('*/10 * * * *', () => {
// Replace 'yoursite.onrender.com' with your actual server URL
ping.sys.probe('');
});
client.on('qr', (qr) => {
// Generate and scan this code with your phone
console.log('QR RECEIVED');
console.log(qrcode.generate(qr, {
small: true
}));
});
client.on('ready', () => {
console.log('Client is ready');
});
client.on('message', async (msg) => {
// console.log(msg);
if (msg.body.toLowerCase() == "hii" || msg.body.toLowerCase() == 'hi' || msg.body === 'hello' || msg.body === 'hey') {
await msg.reply(`Hello, I'm Nebula, Boss will reply you soon`);
}else{
await AI_TEXT_GENERATION(msg.body , msg )
}
});
client.initialize();
app.get('/', (req, res) => {
res.send('Hello, Express!'); // Replace with your desired response
});
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});