[Python] I want to manage 7DaysToDie from Discord! 1/3 (Environment construction) [Python] I want to manage 7DaysToDie from Discord! 2/3 (Creating a BOT that can be managed from Discord) [Python] I want to manage 7DaysToDie from Discord! 3/3 (operation check)
I used to want to write a program that can manage Minecraft from Discord, This time I decided to do 7 Days on Steam, so I made it as if I could do it on 7 Days.
Originally it was troublesome, and opening the console screen and managing it was also troublesome. There are times when you want to leave the operation to a sub-tube other than yourself. I came to the production for some reason.
This program uses Discord Bot and Discord Webhook. Also, I'm still learning Python ~~ with the idea of having fun ~~. If you have any other opinions such as better program writing or blog improvement points, please comment and it will be encouraging.
--Basic Unix knowledge and command can be used. --Have a basic knowledge of Python. (I'm going to write it so that it works almost with copy and paste without it) -Discord must be installed --Discord's API must be available. (Must have Bot installed)
--Use Python3.6.9 (works for 3 series)
$HOME/
┝ python/
┕ discord/
┝ sdtd_run.py
┝ sdtd_start.sh
┕ Sdtd/
┕ command.py
┝ steamcmd
┝ linux32
┝ linux64
┝ .... //The following default directories
┕ sdtd ← This is the directory used this time.
//Used with steamcmd
# yum -y install glibc.i686 libstdc++.i686
//Used on discord
# yum -y install libffi-dev libnacl-dev python3-dev
//Used in python programs
# yum -y install screen lsof awk
# pip install discord.py requests
Make a hole in the port to be used.
# firewall-cmd --permanent --add-port=26900/tcp
# firewall-cmd --permanent --add-port=26900-2603/udp
# firewall-cmd --reload
//Work as a general user from the following.
$ mkdir steamcmd
$ cd steamcmd/
$ curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxf -
$ ./steamcmd.sh
Steam>login anonymous
Steam>force_install_dir sdtd
Steam>app_update 294420 validate
Steam>quit
$ cd sdtd
$ vim startserver.sh
startserver.sh
#!/bin/sh
SERVERDIR=`dirname "$0"`
cd "$SERVERDIR"
PARAMS=$@
CONFIGFILE=
while test $# -gt 0
do
if [ `echo $1 | cut -c 1-12` = "-configfile=" ]; then
CONFIGFILE=`echo $1 | cut -c 13-`
fi
shift
done
if [ "$CONFIGFILE" = "" ]; then
PARAMS="-configfile=serverconfig.xml"
else
if [ -f "$CONFIGFILE" ]; then
echo Using config file: $CONFIGFILE
else
echo "Specified config file $CONFIGFILE does not exist."
exit 1
fi
fi
export LD_LIBRARY_PATH=.
#export MALLOC_CHECK_=0
if [ "$(uname -m)" = "x86_64" ]; then
./7DaysToDieServer.x86_64 -logfile $SERVERDIR/7DaysToDieServer_Data/logs/output_log__`date +%Y-%m-%d__%H-%M-%S`.txt -quit -batchmode -nographics -dedicated $PARAMS
else
echo "7 Days to Die only supports 64 bit operating systems!"
exit 1
fi
vim serverconfig.xml
Since Telnet is used for console operation, description is required. (Because it is localhost, it is OK without a path) The port should be 8081. There is no need to open the port.
serverconfig.xml
<property name="TelnetEnabled" value="true"/> <!-- Enable/Disable the telnet -->
<property name="TelnetPort" value="8081"/> <!-- Port of the telnet server -->
<property name="TelnetPassword" value=""/> <!-- Password to gain entry to telnet interface. If no password is set the server will only listen on the local loopback interface -->
That is all for building the environment. Next, let's do Main Implementation!
Recommended Posts