Skip to content

Commit

Permalink
Merge branch 'experimental'
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardmedicNL committed Nov 5, 2023
2 parents 995f510 + 74251a0 commit e6b3176
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 129 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/servers
/Untitled.png
/ACSERVERS(0.52)
results practice.json
results qualify.json
test.json
test.py
results practice.json
results qualify.json
11 changes: 11 additions & 0 deletions example_discordbotcfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"showlaptimes":"True",
"classes":{
"2017":["ks_ferrari_sf70h"],
"2010":["lotus_exos_125_s1"],
"2004":["ks_ferrari_f2004"],
"80s":["lotus_98t"],
"70s":["ferrari_312t","ks_lotus_72d"],
"60s":["ks_ferrari_312_67","lotus_49"]
}
}
694 changes: 572 additions & 122 deletions leaderboard.py

Large diffs are not rendered by default.

39 changes: 34 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# what does it do:
a server sided script that reads logs from assettoserver for shmoovin score entries and posts them to a leaderboard posted via discord webhooks.
![alt text](screenshot.png)
a server sided script that reads logs from assettoserver for lap times, shmoovin score entries and general server information and posts them to a leaderboard posted via discord webhooks.

it loops trough a parent folder housing all servers and uses a configurable identifier to identify server folders. if it sees a server folder it looks in that folder for a logs folder where it will then loop trough the last log file to find score entries. it will NOT work with different folder structures (example below). it saves the score to a leaderboard txt in the root of the server wich can be added manually to remove or reset scores.
![alt text](screenshot3.png)

![alt text](screenshot4.png)

![alt text](screenshot5.png)

it loops trough a parent folder housing all servers and uses a configurable identifier to identify server folders. if it sees a server folder it looks in that folder for a logs folder where it will then loop trough the last log file to find score entries. it will NOT work with different folder structures (example below). it saves the scores and laptimes to a leaderboard txt and a laptimes txt in the root of the server wich can be added manually to remove or reset scores.

If there is no shmoovin script present in the csp config in the server folders cfg folder it will not trigger and leave the folder alone.
It gets the server name from the server config.

laptimes and full server info can be set on or off in the configs as described below.

# how to use:
1. install python on your system from the python website https://www.python.org/downloads/ make sure to select add python to path
2. install the requests module trough pip with the following command in a terminal
Expand All @@ -18,16 +25,36 @@ python -m pip install requests
```
{
"interval": time in minutes on how often the script should update the leaderboards,
"serverspath": "path/to/server_parent_folder (if using docker make this "servers")",
"serverspath": ["path/to/server_parent_folder1", "path/to/server_parent_folder2"],
"folderindentifier": "identifier to recognize server folder",
"leaderboardlimit": how much entries should be displayed on the leaderboard,
"webhookurl":"url to your discord webhook",
"shmoovindrifturl":["url to drift script"],
"shmoovinovertakeurl":["url to overtake script"]
"shmoovinovertakeurl":["url to overtake script"],
"serveradress":"ip adress of server",
"serveradressdisplay":"ip adress used in bot messages and link (incase serveradress is localhost)",
"onlyleaderboards":"wether or not to show the full server info or leadeboards only, set to "true" or "false" "
}
```
5. save the file and run the script.

* optionally to ignore laptimes or sort by class for a certain server you can create a file in the server root with the name "discordbotcfg.json"
in the file add the following lines:
```
{
"showlaptimes":"True",
"classes":{
"2017":["ks_ferrari_sf70h"],
"2010":["lotus_exos_125_s1"],
"2004":["ks_ferrari_f2004"],
"80s":["lotus_98t"],
"70s":["ferrari_312t","ks_lotus_72d"],
"60s":["ks_ferrari_312_67","lotus_49"]
}
}
```
to define wich car goes in what class make a class entry like above and add the classnames for the car in there within "" seperated by ,

* alternativly you can build your own docker image with the dockerfile provided or use mine with the following command
```
docker run -dit --name shmoovin-discord-leaderboard -v /path/to/assetto/servers:/usr/src/app/servers -v /path/to/config:/usr/src/app/config keyboardmedic/shmoovin-discord-leaderboard:latest
Expand All @@ -43,5 +70,7 @@ docker run -dit --name shmoovin-discord-leaderboard -v /path/to/assetto/servers:

* to remove or resend a leaderboard delete the corresponding txt file with the server name in the config folder and manually delete the leaderboard message on discord.

* to remove an entry from the leaderboards delete the entry in the corresponding file (leaderboard.txt or laptimes.txt in the server root) and delete the corresponding log line in the logs

# disclaimer
scripts are written by an amateur, use at your own risk...
Binary file removed screenshot.png
Binary file not shown.
Binary file added screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e6b3176

Please sign in to comment.