VHTG - Valheim to Telegram Message Processor
VHTG is a command-line application written in Go that reads text messages from the standard input or a Docker container with the Valheim server, matches them using regular expressions, and sends formatted messages to a specified Telegram chat using the Telegram Bot API.
Features
- Automatically process Valheim server logs
- Support for reading logs from standard input or a Docker container
- Send formatted messages to a specified Telegram chat
- Test mode for outputting formatted messages without sending them to Telegram
Prerequisites
- Go 1.18 or higher
- A Telegram bot token (you can create a new bot by talking to the BotFather)
- A Telegram chat ID to send messages to (you can use a personal chat, group chat, or channel)
Installation
Clone the repository and navigate to the project directory:
git clone https://github.com/ffix/vhtg.git
cd vhtg
Build
Use the provided Makefile to build the application for your platform:
make vhtg # For your current platform
make all # For all supported platforms
Usage
- Set the
TELEGRAM_BOT_TOKEN
, TELEGRAM_CHAT_ID
, and SERVER_PASS
environment variables:
export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
export TELEGRAM_CHAT_ID="your-telegram-chat-id"
export SERVER_PASS="your-server-password"
- In standard mode, pipe the application from the Valheim server:
./valheim-server | ./vhtg
- To enable test mode and only output the formatted message to the standard output without sending it to Telegram, add the
--test
flag:
./valheim-server | ./vhtg --test
- To integrate with Docker and poll the logs internally, add the
--docker
flag:
./vhtg --docker
Configuration
The VHTG application is primarily configured using environment variables. These include:
TELEGRAM_BOT_TOKEN
: Your Telegram bot token
TELEGRAM_CHAT_ID
: The Telegram chat ID to send messages to
SERVER_PASS
: Your Valheim server password
Running with Docker Compose
To run the application inside a Docker container, you can use the following Docker Compose configuration:
services:
vhtg:
build:
context: vhtg
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
env_file:
- "env.valheim"
restart: always
stop_grace_period: 2m
Contributing
Contributions to the VHTG project are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository
- Create a new branch for your changes (
git checkout -b my-feature
)
- Commit your changes (
git commit -am 'Add my feature'
)
- Push the changes to the branch (
git push origin my-feature
)
- Create a new pull request
Please make sure to follow the project's coding standards and include tests for any new features or bug fixes.
Support
If you encounter any issues or need help using the VHTG application, please:
- Check the project's documentation and README for any relevant information
- Search the project's issue tracker for any similar issues
- If you cannot find a solution, create a new issue with a clear description of the problem, steps to reproduce it, and any relevant logs or error messages
We will do our best to address your concerns and provide assistance.
License
This project is licensed under the MIT License.