1tbfree commited on
Commit
02591b4
·
verified ·
1 Parent(s): defed3e

Create bot.js

Browse files
Files changed (1) hide show
  1. bot.js +71 -0
bot.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const axios = require('axios');
2
+
3
+ // Chat application URL (update with your actual URL)
4
+ const LOGIN_URL = 'https://heckergd.serv00.net/pchat/login.php'; // Adjust this based on your setup
5
+ const CHAT_APP_URL = 'https://heckergd.serv00.net/pchat/chat.php'; // Adjust this based on your setup
6
+
7
+ // User credentials (replace with actual credentials)
8
+ const username = 'user';
9
+ const password = 'test';
10
+
11
+ // Function to fetch the login page and get PHPSESSID
12
+ async function fetchSessionId() {
13
+ try {
14
+ const response = await axios.get(LOGIN_URL);
15
+ const cookies = response.headers['set-cookie'];
16
+
17
+ // Extract PHPSESSID from cookies
18
+ const sessionId = cookies.find(cookie => cookie.startsWith('PHPSESSID')).split(';')[0];
19
+ console.log(`Fetched PHPSESSID: ${sessionId}`);
20
+ return sessionId;
21
+ } catch (error) {
22
+ console.error('Error fetching session ID:', error);
23
+ }
24
+ }
25
+
26
+ // Function to send random messages to the chat application
27
+ async function sendRandomMessage(sessionId) {
28
+ const messages = [
29
+ "Hello everyone!",
30
+ "How's it going?",
31
+ "Just checking in!",
32
+ "What's up?",
33
+ "Need any help?",
34
+ "Hope you're having a great day!",
35
+ "Did you see the latest news?",
36
+ "Random thoughts...",
37
+ "Let's chat!",
38
+ "How can I assist you today?"
39
+ ];
40
+
41
+ const randomMessage = messages[Math.floor(Math.random() * messages.length)];
42
+
43
+ try {
44
+ await axios.post(CHAT_APP_URL, {
45
+ message: randomMessage
46
+ }, {
47
+ headers: {
48
+ 'Cookie': sessionId,
49
+ 'Content-Type': 'application/json'
50
+ }
51
+ });
52
+
53
+ console.log(`Sent: ${randomMessage}`);
54
+ } catch (error) {
55
+ console.error('Error sending message:', error);
56
+ }
57
+ }
58
+
59
+ // Main function to run the bot
60
+ async function runBot() {
61
+ const sessionId = await fetchSessionId();
62
+ if (sessionId) {
63
+ console.log("Chat Bot is running! Sending random messages...");
64
+
65
+ // Send a random message every 5 seconds
66
+ setInterval(() => sendRandomMessage(sessionId), 5000);
67
+ }
68
+ }
69
+
70
+ // Start the bot
71
+ runBot();