For complete overview of the project, please visit the Unity package GitHub repository.
This is a Node.js app that serves two purposes:
- Run a Telegram bot
- Serve a game (actually, an
index.html
file)
Note that this repo is essentially only that. So it isn't mandatory to be used with a Unity game. Actually, the project from which this project has been forked implements a fully js T-Rex game.
This project contains a very simple Unity Game, which uses the unity-telegram-game package.
The first step is to create a Telegram bot. Talk to the BotFather and store the token it will give you.
In this app, we will only do two things related to the bot:
- Listen for commands and serve the game when asked with
/game
- Listen for inline queries (this enables you to type "@YourNameBot" in any chat and get prompted with the game)
- Deploy a Node.js app. This documentation will not cover this part (this is because it is out of the scope of the project, not at all because I already forgot how I did it). However, here are some steps to deploy it on a VPS (something like that) :
- Install Node and yarn
- Install pm2 and use it to start the Node app
- Configure a nginx server (pay attention to how you're declaring the
public
folder in the config) - Don't forget to cry because your nginx config is not working
- Pay attention to which ports are used and need to be opened: don't forget you have two services running, the express server and the telegram bot.
- Add a SSL certificate
- Upload your WebGL game in the
public
folder - Add a
.env
file with the following content:The score tokens are the numbers you will use to obfuscate the score. They must be also set in the Unity game.BOT_TOKEN=<your-telegram-bot-token> SCORE_TOKEN = "<your-score-token-1>;<your-score-token-2>;..."
- You're good to go.