-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOctoCore.php
64 lines (53 loc) · 1.87 KB
/
OctoCore.php
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
<?php
// Define the bot prefix
$prefix = '*';
// Get the message from the user
$message = isset($_POST['message']) ? $_POST['message'] : '';
// Check if the message is not empty
if (!empty($message)) {
// Check if the message starts with the bot prefix
if (substr($message, 0, strlen($prefix)) === $prefix) {
// Extract the command and parameters
$commandWithParams = trim(substr($message, strlen($prefix)));
$commandParts = explode(' ', $commandWithParams);
$command = $commandParts[0];
$params = array_slice($commandParts, 1);
// Get the command file
$commandFile = "cmds/{$command}.php";
// Check if the command file exists
if (file_exists($commandFile)) {
// Start output buffering to capture the command's response
ob_start();
// Include the command file
include $commandFile;
// Get the command's response from the output buffer
$response = ob_get_clean();
// Output the response
echo $response;
} else {
// Command not found
echo "✖️cmd not found";
}
} else {
// No prefix, redirect to nopref.php
$commandFile = "nopref.php";
// Check if the command file exists
if (file_exists($commandFile)) {
// Start output buffering to capture the command's response
ob_start();
// Include the command file
include $commandFile;
// Get the command's response from the output buffer
$response = ob_get_clean();
// Output the response
echo $response;
} else {
// nopref.php not found
echo "Command handler for commands without prefix not found.";
}
}
} else {
// Empty message
echo "Message is empty.";
}
?>