Project Zomboid

Project Zomboid

Not enough ratings
diZcord
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
66.326 KB
Dec 30, 2023 @ 11:00am
1 Change Note ( view )

Subscribe to download
diZcord

Description
THIS ITEM DOES NOT WORK BY SUBSCRIBING

View Github pages at bottom of description

Discord integration for Project Zomboid. Sends feature-rich information to a text channel in discord. I've now also added a discord bot to control the discord server from a discord channel. BE VERY CAREFUL WITH THIS!

Requirements
This needs to be run on the instance that is running the Project Zomboid server. Obviously the OS needs to be Linux with Bourne Again Shell (BASH) and a few other dependencies, listed later. You'll also have to have your own Discord Server (or have admin rights to the server) to get a Webhook set up. The user that you use to install diZcord should have sudo access.




Instructions

Before starting, shut down your Project Zomboid server by entering "quit" into the server's console as an admin.

Create a new file in your home folder called
init.sh
with the following code in there (I'll describe it line-for-line later):
#! /bin/bash LATEST_VERSION=$(curl -sL https://api.github.com/repos/Blyzz616/diZcord/releases/latest | jq -r '.tag_name') CURRENT_VERSION=$(sudo cat /opt/dizcord/current.version 2>/dev/null) I_AM=$(whoami) if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then NO_V=$(echo "$LATEST_VERSION" | sed 's/v//') sudo mkdir -p /opt/dizcord/ wget -q -O "/tmp/dizcord-$NO_V.tar.gz" "https://github.com/Blyzz616/diZcord/archive/$LATEST_VERSION.tar.gz" tar -zxvf "/tmp/dizcord-$NO_V.tar.gz" -C /opt/dizcord/ --strip-components=1 >/dev/null sudo chown -R "$I_AM":"$I_AM" /opt/dizcord rm -r /tmp/di?cord* echo "$LATEST_VERSION" > /opt/dizcord/current.version fi sudo chmod ug+x /opt/dizcord/*.sh

Make the script executable:

sudo usermod ug+x init.sh

Then run the script
./init.sh
It will download the latest version of diZcord from here and put all the files in /opt/dizcord/

Now head on over to
/opt/dizcord/
and run the Wizard

cd /opt/dizcord/ ./wizard.sh





Explanation of the init.sh file

LATEST_VERSION=$(curl -sL https://api.github.com/repos/Blyzz616/diZcord/releases/latest | jq -r '.tag_name')

curl -sL: This command is used to make an HTTP GET request to the specified URL (https://api.github.com/repos/Blyzz616/diZcord/releases/latest).
| jq -r '.tag_name': The output of the curl command is passed through jq, and extracts the value of the 'tag_name' key from the JSON response, effectively retrieving the latest version of the diZcord release from GitHub. The result is stored in the variable LATEST_VERSION.

CURRENT_VERSION=$(sudo cat /opt/dizcord/current.version 2>/dev/null)

sudo cat /opt/dizcord/current.version: Reads the content of the file /opt/dizcord/current.version. 2>/dev/null: Redirects any error output to /dev/null (a special file that discards the output). If the file doesn't exist or there is an error reading it, this line won't produce an error message. The result is stored in the variable CURRENT_VERSION.

I_AM=$(whoami): Retrieves the current username and assigns it to the variable I_AM.

if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then: Checks whether the current version ($CURRENT_VERSION) is not equal to the latest version ($LATEST_VERSION).

NO_V=$(echo "$LATEST_VERSION" | sed 's/v//'): Removes the leading 'v' from the latest version and assigns the result to the variable NO_V.

sudo mkdir -p /opt/dizcord/: Creates the directory /opt/dizcord/ if it doesn't exist.

wget -q -O "/tmp/dizcord-$NO_V.tar.gz" "https://github.com/Blyzz616/diZcord/archive/$LATEST_VERSION.tar.gz": Downloads the diZcord release tarball (zip file) from GitHub and saves it as /tmp/dizcord-$NO_V.tar.gz.

tar -zxvf "/tmp/dizcord-$NO_V.tar.gz" -C /opt/dizcord/ --strip-components=1 >/dev/null: Extracts the contents of the tarball to /opt/dizcord/ while suppressing output.

sudo chown -R "$I_AM":"$I_AM" /opt/dizcord: Changes the ownership of the /opt/dizcord/ directory and its contents to the current user.

rm -r /tmp/di?cord*: Removes temporary files in /tmp/ that match the pattern /tmp/di?cord*.

echo "$LATEST_VERSION" > /opt/dizcord/current.version: Writes the latest version to the file /opt/dizcord/current.version.

fi: Ends the if block.

sudo chmod ug+x /opt/dizcord/*.sh: Changes the permissions of all .sh files in the /opt/dizcord/ directory to make them executable by the owner and the owner's group.
As all the code in wizard.sh is in github, all are free to view it and inspect it. You can even paste it into a GPT and ask a Generative LLM if there is any malicious code in there.



Workshop ID: 3126850418
Mod ID: diZcord




It needs to be installed from Github. Head on over to

https://github.com/Blyzz616/diZcord
9 Comments
Arduu Sep 7, 2024 @ 5:35am 
@Blyzz.com nice to hear!
Blyzz.com  [author] Sep 6, 2024 @ 7:49pm 
@ardu, workl in progress bud, hopefully, I'll have a more turing complete product at some point :-)
thanks for using dizcord!
Arduu Aug 14, 2024 @ 12:20pm 
great for discord server u should consider install this if u have linux hope we will get some update on this. For a beginner user linux was kinda hard to run it its kinda hardcoded in my opinion with wher are files located so u have to change it manualy
twitch.tv/edwin_fox Aug 7, 2024 @ 8:43pm 
I really love your mod - and Linux! <3
Mihalich™ Apr 8, 2024 @ 9:52am 
@Blyzz.com
Well, too bad there's no way to use this on Windows at the moment.
Hopefully you will be able to do it in the future!
Blyzz.com  [author] Apr 8, 2024 @ 9:49am 
Hi @Mihalich™, yes, that's correct, this was built using BASH with specific references to the file locations on a Linux server. But, what I might do at some point is refactor this to Python with the intention of getting it working on Windows. However, I will probably only tackle this after B42 is released.
Mihalich™ Mar 25, 2024 @ 8:34am 
Hi!
Am I right to understand that there is no way to run this on Windows ? Why is that ? :sheep_cry:
Blyzz.com  [author] Jan 1, 2024 @ 9:59am 
@B4N5TER: awesome, thanks for your input. As you can see I've made my code open-source, and available on Github. You're welcome to take whatever you like. Also If you're in the mood feel free to contribute as well. I know I'm not the best coder out there and hoping to find more people to contribute to make it better.

Also the restart command does indeed take an argument, i've set mine up to take a maximum of 5 minutes though, and if there's no argument, then it defaults to 5, sending in-game warnings to anyone that has their text chat window open every minute, then at 30s, 10s, 5,4,3,2, and 1s - might be overkill, but I kinda like the sense of urgency it creates. Also warnings to discord for the on-minute events.
OnlyBonz Dec 31, 2023 @ 8:28pm 
I do something similar to what this does for my server. I'm also using screen.

I've briefly looked at yours after a friend sent it to me but there's a couple things I do differently. Not saying they're better but food for thought.

My shutdown script takes an argument for how many minutes and then warns the player at logical increments, e.g.
pzres 18
- "shutdown in 18 minutes"
- "shutdown in 15 minutes"
- "shutdown in 5"

Also on my list of things to do is to implement a queue system, then send commands to the queue system, because when I send commands at the same time another command is being sent to the screen sometimes it combines the output causing gibberish.

I'm currently thinking the most resilient way to do this is to have most of my commands check if the queue system is up, and if it's not up, send it directly.

I've noticed that some actions (e.g. rewhitelisting) can mess with the server ingame experience if you don't rate limit them.