-
-
Notifications
You must be signed in to change notification settings - Fork 139
Full documentation
This document is for developpers / integrator for the eBot tools. If you are a common user, just don't read it, it will confuse yourself ! :)
To understand how eBot works, you need to understand the scheme. eBot has 2 distingued parts:
- The PHP daemon + NodeJS server
- The web pannel
eBot can works without the web pannel, this is just to control eBot and see the results / stats. You can develop one on your own !
To understand how the eBot works, you need to know how the bot grab the datas. CS:GO have a log stream in UDP that we read. With a simple rcon commands, the bot add his own server address/port that it listen and the server begin to send the data.
Major common issue is a firewall who is blocking the UDP stream between the server and eBot, if you don't have any output on the eBot daemon, it's that kind of issue.
The eBot daemon works like this:
- Each 3 seconds, it check in the database for new matchs
- Each loop time, it read from the UDP Socket
- Each loop time, the TaskManager is executed to process all tasks
eBot has a control interface trought the UDP server. Here is the list of the commands available:
- stop
- stopNoRs
- executeCommand
- passknife
- forceknife
- forceknifeend
- forcestart
- stopback
- pauseunpause
- fixsides
- streamerready
- goBackRounds
- skipmap
We will see later how to communicate and send this kind of command
The NodeJS server is just a forwarder, it forward some messages to all connected users. It's the bot who send the datas.
The server can send too some commands to the eBot server, it's not required, you can make it on your own. The NodeJS server is required for the auto demos upload, when a match end, the demos it pushed to the server, who archive and rename the file into the right dir.
Since Socket.io update, we dropped native WebSocket support for better performance. We won't have no more issue with strange disconnection or something like that
To interact with eBot, we have developped an encrypted system to send secured message to eBot. As eBot is listenning a public server IP/PORT, anybody can send an UDP packet to the server. To secure the whole, we use AES encryption with an unique key per match.
It's simple, each match have his own cryptkey, and to detect the match_id / encrypted message, we use a JSON string. You will need to send a string like this:
The cryptkey field on the database is "config_authkey"
["COMMAND ENCRYPTED", "#MATCH_ID"]
The order is very important, as for now we don't use an associative array for the data. It's an upgrade that we will do in the future
For now, when you send a command from the eBot-WEB, the command is sent via the NodeJS server who forward it to the eBot server.
You can too send this kind of packet to the eBot server directly instead of sending the message to the NodeJS server.
As we are PHP Developper, we will put some example soon online :)
When you encrypt your message, you have to follow a format. We plan to change this format soon.
- stopNoRs: Stop the match without restart round | #matchid stopNoRs #serverip | sample: 1 stopNoRs 192.168.1.1:27015
- stop: Stop the match with a restart round | #matchid stop #serverip | sample: 1 stop 192.168.1.1:27015
- executeCommand: Send an rcon command to the game server, reply will follow on the NodeJS server on the rcon channels | #matchid executeCommand #serverip #command | sample: 1 executeCommand 192.168.1.1:27015 mp_restartgame 1
- passknife: Pass the knife round (if in warmup knife) | #matchid passknife #serverip | sample: 1 passknife 192.168.1.1:27015
- forceknife: Force the start of the knife round | #matchid forceknife #serverip | sample: 1 forceknie 192.168.1.1:27015
- forceknifeend: End the knife round and go on the warmup | #matchid forceknifeend #serverip | sample: 1 forceknifeend 192.168.1.1:27015
- forcestart: For the start of a match (if in warmup) | #matchid forcestart #serverip | sample: 1 forcestart 192.168.1.1:27015
- stopBack: Stop the match | #matchid stopBack #serverip | sample: 1 stopBack 192.168.1.1:27015
- pauseunpause: If match is paused, it will unpause, if match is unpaused, it will pause | #matchid pauseunpause #serverip | sample: 1 pauseunpause 192.168.1.1:27015
- fixsides: Force to send the team names on the server | #matchid fixsides #serverip | sample: 1 fixsides 192.168.1.1:27015
- streamerready: If the config stream ready is set, it will send a message to set that streamer are ready | #matchid streamready #serverip | sample: 1 streamerready 192.168.1.1:27015
- goBackRounds: Load a backup round, be carrefull when using this func ! | #matchid goBackRounds #serverip #roundId | sample: 1 goBackRounds 192.168.1.1:27015 5
On the eBot-WEB platform, we integrated an encryption class for JavaScript.
Here is a sample code:
javascript function encryptCommand(matchId, eventData, serverIp, authkey) { var data = matchId + " " + eventData + " " + serverIp; data = Aes.Ctr.encrypt(data, authkey, 256); var content = JSON.stringify([data, serverIp]); return content; }
If the socket.io is declared, you just need to make this to send the packet:
javascript socket.emit("matchCommandSend", encryptedData);
To send a command via PHP, it's the same than JS but with other class.
For the class, you should use this: https://github.com/deStrO/eBot-CSGO/blob/master/src/eTools/Utils/Encryption.php
Here is a code sample: ```php <?php function encryptCommand($matchId, $eventData, $serverIp, $authkey) { $data = $matchId . " " . $eventData . " " . $serverIp; $data = Encryption::encrypt($data, $authkey, 256); $content = json_encode(array($data, $serverIp)); return content; }
function sendCommandToeBot($message) {
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_sendto($socket, $message, strlen($message), 0, "192.168.1.1", 12340);
}
?>
```