forked from Victorkingb/Queen-amy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.js
134 lines (116 loc) Β· 5.04 KB
/
Index.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
const { Client, LocalAuth, MessageMedia } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');
const fs = require('fs');
// Initialize the WhatsApp client
const client = new Client({
authStrategy: new LocalAuth(),
puppeteer: {
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
}
});
// Generate QR Code for authentication
client.on('qr', (qr) => {
console.log('π Scan this QR code with your WhatsApp to log in as Queen Amy:');
qrcode.generate(qr, { small: true });
});
// Successful login
client.on('ready', () => {
console.log('π Queen Amy is now ready to rule the WhatsApp kingdom!');
});
// Event listener for incoming messages
client.on('message', async (msg) => {
const command = msg.body.toLowerCase();
// Respond to greetings
if (command === 'hello' || command === 'hi') {
msg.reply('π Greetings! I am Queen Amy. How can I assist you today?');
}
// Help command
else if (command === '!help') {
msg.reply(`
π *Queen Amy Commands* π
1. *!help* - Displays this help menu.
2. *!joke* - Get a funny joke to brighten your day.
3. *!quote* - Receive an inspirational quote.
4. *!meme* - Get a random meme.
5. *!remindme <time> <message>* - Set a reminder.
6. *!weather <city>* - Check the weather in your city.
7. *!funfact* - Learn a fun fact.
8. *!gif <search term>* - Get a random GIF.
9. *!motivate* - Receive some motivation!
`);
}
// Joke command
else if (command === '!joke') {
const jokes = [
"Why donβt skeletons fight each other? They donβt have the guts. π",
"I told my wife she should embrace her mistakes. She hugged me. π",
"Why did the scarecrow win an award? Because he was outstanding in his field! πΎ"
];
msg.reply(jokes[Math.floor(Math.random() * jokes.length)]);
}
// Quote command
else if (command === '!quote') {
const quotes = [
"βThe greatest glory in living lies not in never falling, but in rising every time we fall.β - Nelson Mandela",
"βThe way to get started is to quit talking and begin doing.β - Walt Disney",
"βDonβt watch the clock; do what it does. Keep going.β - Sam Levenson"
];
msg.reply(quotes[Math.floor(Math.random() * quotes.length)]);
}
// Meme command (send an image)
else if (command === '!meme') {
const memePath = './memes/meme.jpg'; // Replace with the path to a meme image
const memeMedia = MessageMedia.fromFilePath(memePath);
client.sendMessage(msg.from, memeMedia);
}
// Fun fact command
else if (command === '!funfact') {
const funFacts = [
"Did you know? The shortest war in history lasted only 38 minutes!",
"Honey never spoils. Archaeologists have found pots of honey over 3,000 years old in ancient Egyptian tombs.",
"A single strand of Spaghetti is called a Spaghetto. π"
];
msg.reply(funFacts[Math.floor(Math.random() * funFacts.length)]);
}
// GIF command
else if (command.startsWith('!gif ')) {
const searchTerm = command.replace('!gif ', '');
// You would need to use an API like GIPHY to fetch GIFs dynamically
msg.reply(`π Sorry, this feature isn't live yet. Imagine a GIF about *${searchTerm}*!`);
}
// Weather command (mock response, replace with real API)
else if (command.startsWith('!weather ')) {
const city = command.replace('!weather ', '');
msg.reply(`π The weather in *${city}* is currently sunny with a slight chance of fabulousness. βοΈπ`);
}
// Reminder command (simple, without persistence)
else if (command.startsWith('!remindme ')) {
const reminderDetails = command.replace('!remindme ', '').split(' ');
const time = parseInt(reminderDetails[0], 10);
const reminderMessage = reminderDetails.slice(1).join(' ');
if (!isNaN(time) && reminderMessage) {
msg.reply(`π Reminder set for ${time} minutes: "${reminderMessage}"`);
setTimeout(() => {
msg.reply(`π Reminder: ${reminderMessage}`);
}, time * 60000);
} else {
msg.reply('π Please provide a valid time in minutes and a message. Example: *!remindme 5 Take a break*');
}
}
// Motivate command
else if (command === '!motivate') {
const motivations = [
"π Believe in yourself. You are braver than you think, stronger than you seem, and smarter than you think.",
"π Success is not final, failure is not fatal: It is the courage to continue that counts.",
"π Your limitationβitβs only your imagination."
];
msg.reply(motivations[Math.floor(Math.random() * motivations.length)]);
}
// Unknown command handler
else if (command.startsWith('!')) {
msg.reply(`π I'm not sure what you mean. Type *!help* to see what I can do!`);
}
});
// Start the client
client.initialize();