Bot01 / bot.js
1tbfree's picture
Create bot.js
02591b4 verified
const axios = require('axios');
// Chat application URL (update with your actual URL)
const LOGIN_URL = 'https://heckergd.serv00.net/pchat/login.php'; // Adjust this based on your setup
const CHAT_APP_URL = 'https://heckergd.serv00.net/pchat/chat.php'; // Adjust this based on your setup
// User credentials (replace with actual credentials)
const username = 'user';
const password = 'test';
// Function to fetch the login page and get PHPSESSID
async function fetchSessionId() {
try {
const response = await axios.get(LOGIN_URL);
const cookies = response.headers['set-cookie'];
// Extract PHPSESSID from cookies
const sessionId = cookies.find(cookie => cookie.startsWith('PHPSESSID')).split(';')[0];
console.log(`Fetched PHPSESSID: ${sessionId}`);
return sessionId;
} catch (error) {
console.error('Error fetching session ID:', error);
}
}
// Function to send random messages to the chat application
async function sendRandomMessage(sessionId) {
const messages = [
"Hello everyone!",
"How's it going?",
"Just checking in!",
"What's up?",
"Need any help?",
"Hope you're having a great day!",
"Did you see the latest news?",
"Random thoughts...",
"Let's chat!",
"How can I assist you today?"
];
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
try {
await axios.post(CHAT_APP_URL, {
message: randomMessage
}, {
headers: {
'Cookie': sessionId,
'Content-Type': 'application/json'
}
});
console.log(`Sent: ${randomMessage}`);
} catch (error) {
console.error('Error sending message:', error);
}
}
// Main function to run the bot
async function runBot() {
const sessionId = await fetchSessionId();
if (sessionId) {
console.log("Chat Bot is running! Sending random messages...");
// Send a random message every 5 seconds
setInterval(() => sendRandomMessage(sessionId), 5000);
}
}
// Start the bot
runBot();