Skip to content

jaumebecks/valheim-server-notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Valheim Server Notifier (aka Odin)

Using Python
Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. Contact
  7. Acknowledgements

About The Project

This project's purpose is to increase the experience of playing Valheim in a dedicated server with some friends, by notifying in Discord some Valheim Server log events, such as ServerOn, ServerOff, PlayerJoined, PlayerDead, etc.

Essentially, it continuously reads the server logs and reacts to some events that match certain patterns. Whenever a match appear, it generates a template for sending alerts to a Discord server. It has the capability to adapt to rotating log files, too

Built With

Getting Started

Prerequisites

You'll need to install the following in order to be able to run the application

And to configure some envvars in your Valheim Server

VALHEIM_LOG_PATH # Path to current server console log
DISCORD_WEBHOOK_URL # Discord Webhook URL

How to find server console log path

It depends on how you configured your Valheim Server. For example, for LinuxGSM installations, it's located in /home/<your-username>/log/console/vhserver-console.log by default

How to create a Webhook in Discord

It's really simple! Please refer to their Official Documentation for better guidelines

Installation

To get a local copy up and running follow these simple steps.

First, we'll get the code

Get the code

In your Valheim Server

  1. Clone the repo
git clone https://github.com/jaumebecks/valheim-server-notifier.git
  1. Go into project root
cd valheim-server-notifier
  1. Update .env file
cp .env.dist .env
  1. Open .env file and fill it with proper values

Run script automatically on server start

We're going to create a systemctl service that will be running always in our server. To do so, first we need to create a file under /etc/systemd/system/ folder

  1. Create a file with your preffered name
sudo touch /etc/systemd/system/valheim-odin.service
  1. Edit the file with your preffered editor and put
[Unit]
Description=Valheim Server Notifier
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=1s
User=<your-username>
Group=<your-groupname>
ExecStart=/usr/bin/python3 /home/<your-username>/valheim-server-notifier/odin/main.py
EnvironmentFile=/home/<your-username>/valheim-server-notifier/.env
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s INT $MAINPID
LimitNOFILE=100000

[Install]
WantedBy=multi-user.target

Remember to update the variables with proper ones for your own setup

  1. Enable the service in your server
systemctl daemon-reload
systemctl start valheim-odin.service
systemctl enable valheim-odin.service

And that's it! Now the python script will be reading from Valheim server logs, waiting to post any event into Discord :D

Usage

To run the script in local

VALHEIM_LOG_PATH=<fill-with-your-log-file> DISCORD_WEBHOOK_URL=<fill-with-your-webhook-url> python3 odin/main.py

Remember to add some envvars first

To check the logs for systemctl service

journalctl -u valheim-odin.service

Examples

Server On server-on
Server Off server-on
Player Joined server-on
Player Died server-on

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Jaume Jiménez - @jaumebecks

Project Link: https://github.com/jaumebecks/valheim-server-notifier

LinkedIn

Acknowledgements

About

Bot for publishing Valheim log based events into Discord via Webhooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages