add slack envs

* add slack flush api
This commit is contained in:
Smith
2023-08-17 18:41:41 +02:00
parent 842d5fb440
commit 4aa90f11b0
11 changed files with 89 additions and 13 deletions

View File

@@ -17,6 +17,12 @@ spec:
- key: TELEGRAM_BOT_TOKEN
scope: RUN_TIME
value: ""
- key: SLACK_BOT_TOKEN
scope: RUN_TIME
value: ""
- key: SLACK_APP_TOKEN
scope: RUN_TIME
value: ""
- key: STEAM_WEB_API_KEY
scope: RUN_TIME
value: ""

View File

@@ -12,6 +12,12 @@ on:
telegram_bot_token:
description: 'Telegram bot token'
type: string
slack_bot_token:
description: 'Slack bot token'
type: string
slack_app_token:
description: 'Slack app token'
type: string
steam_web_api_key:
description: 'Steam web API key'
type: string
@@ -30,14 +36,20 @@ jobs:
INP_SECRET=$(jq -r '.inputs.secret' $GITHUB_EVENT_PATH)
INP_DISCORD_BOT_TOKEN=$(jq -r '.inputs.discord_bot_token' $GITHUB_EVENT_PATH)
INP_TELEGRAM_BOT_TOKEN=$(jq -r '.inputs.telegram_bot_token' $GITHUB_EVENT_PATH)
INP_SLACK_BOT_TOKEN=$(jq -r '.inputs.slack_bot_token' $GITHUB_EVENT_PATH)
INP_SLACK_APP_TOKEN=$(jq -r '.inputs.slack_app_token' $GITHUB_EVENT_PATH)
INP_STEAM_WEB_API_KEY=$(jq -r '.inputs.steam_web_api_key' $GITHUB_EVENT_PATH)
echo ::add-mask::$INP_SECRET
echo ::add-mask::$INP_DISCORD_BOT_TOKEN
echo ::add-mask::$INP_TELEGRAM_BOT_TOKEN
echo ::add-mask::$INP_SLACK_BOT_TOKEN
echo ::add-mask::$INP_SLACK_APP_TOKEN
echo ::add-mask::$INP_STEAM_WEB_API_KEY
echo secret=$INP_SECRET >> $GITHUB_OUTPUT
echo discord_bot_token=$INP_DISCORD_BOT_TOKEN >> $GITHUB_OUTPUT
echo telegram_bot_token=$INP_TELEGRAM_BOT_TOKEN >> $GITHUB_OUTPUT
echo slack_bot_token=$INP_SLACK_BOT_TOKEN >> $GITHUB_OUTPUT
echo slack_app_token=$INP_SLACK_APP_TOKEN >> $GITHUB_OUTPUT
echo steam_web_api_key=$INP_STEAM_WEB_API_KEY >> $GITHUB_OUTPUT
echo SET_ARGS='' >> $GITHUB_ENV
echo UNSET_ARGS='' >> $GITHUB_ENV
@@ -57,6 +69,16 @@ jobs:
- if: inputs.telegram_bot_token == '-'
run: echo UNSET_ARGS='${{ env.UNSET_ARGS }} TELEGRAM_BOT_TOKEN' >> $GITHUB_ENV
- if: inputs.slack_bot_token != '' && inputs.slack_bot_token != '-'
run: echo SET_ARGS='${{ env.SET_ARGS }} SLACK_BOT_TOKEN="${{ steps.masked_inputs.outputs.slack_bot_token }}"' >> $GITHUB_ENV
- if: inputs.slack_bot_token == '-'
run: echo UNSET_ARGS='${{ env.UNSET_ARGS }} SLACK_BOT_TOKEN' >> $GITHUB_ENV
- if: inputs.slack_app_token != '' && inputs.slack_app_token != '-'
run: echo SET_ARGS='${{ env.SET_ARGS }} SLACK_APP_TOKEN="${{ steps.masked_inputs.outputs.slack_app_token }}"' >> $GITHUB_ENV
- if: inputs.slack_app_token == '-'
run: echo UNSET_ARGS='${{ env.UNSET_ARGS }} SLACK_APP_TOKEN' >> $GITHUB_ENV
- if: inputs.steam_web_api_key != '' && inputs.steam_web_api_key != '-'
run: echo SET_ARGS='${{ env.SET_ARGS }} STEAM_WEB_API_KEY="${{ steps.masked_inputs.outputs.steam_web_api_key }}"' >> $GITHUB_ENV
- if: inputs.steam_web_api_key == '-'

View File

@@ -1,5 +1,5 @@
# <img src="https://github.com/a-sync/game-server-watcher/assets/14183614/66a8ffa8-c547-4f9c-b312-4c855da80c20" width="40" align="left"> Game Server Watcher
A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎
A simple discord/telegram/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎
# About the Project
The main goals of this repo:
@@ -10,7 +10,7 @@ The main goals of this repo:
1. graciously add more features based on community feedback via [discord](https://discord.gg/4tsbftsGJz) and [github](https://github.com/a-sync/game-server-watcher/discussions/new?category=ideas-requests)
# Screenshots
<img src="https://user-images.githubusercontent.com/14183614/162092529-e1645b44-2650-4893-8123-7ba187b1f51c.png" height="360"> <img src="https://user-images.githubusercontent.com/14183614/162092488-f28bd60c-88bf-4b1e-a31e-d7dca51d8c28.png" height="360"> <img src="https://user-images.githubusercontent.com/14183614/167517240-a4d02cb2-8037-44c0-abaa-c92901357e35.png" height="360">
<img src="https://user-images.githubusercontent.com/14183614/162092529-e1645b44-2650-4893-8123-7ba187b1f51c.png" height="360"> <img src="https://user-images.githubusercontent.com/14183614/162092488-f28bd60c-88bf-4b1e-a31e-d7dca51d8c28.png" height="360"> <img src="https://github.com/a-sync/game-server-watcher/assets/14183614/6c226306-b7a1-4ed6-9dd9-ab43a136e7e0" height="360"> <img src="https://user-images.githubusercontent.com/14183614/167517240-a4d02cb2-8037-44c0-abaa-c92901357e35.png" height="360">
# Project Status
The code itself is stable and continuously tested/deployed from the master branch.
@@ -22,13 +22,13 @@ The project is in a very early stage. More detailed customization options and fe
* with configurable fields. eg.: time,name,ping,score
* configurable field & order to sort by
* max length for player names & nr of players
* custom embed fields for discord
* custom embed fields for discord/slack
* ~~configurable time zone offset for graph x-axis~~
* refresh on reaction
* watched players (notify when a watched player enters/leaves the server)
* detect when the server goes offline, notify when player number crosses a threshold
* bot commands (reinit message, cleanup, start/stop, post server status, configure)
* more integrations: slack, ms teams, twillio (email, sms)
* more integrations: ~~telegram~~, ~~slack~~, ms teams, twillio (email, sms)
* ~~web ui to manage & configure the servers and bots~~
* put custom information in the channel name or bot status (online status indicator, number of players, map)
* github action workflows to deploy to other cloud providers (aws, linode, atlantic, vultr, pikapods, okteto, ibm cloud etc.)
@@ -82,6 +82,7 @@ Refer to the wiki on how to acquire tokens for:
* [steam](https://github.com/a-sync/game-server-watcher/wiki/Steam-Web-API-key)
* [discord](https://github.com/a-sync/game-server-watcher/wiki/Discord-bot-token)
* [telegram](https://github.com/a-sync/game-server-watcher/wiki/Telegram-bot-token)
* [slack](https://github.com/a-sync/game-server-watcher/wiki/Slack-bot-token)
## Managing the service
**GSW Control Panel** is a web based UI that let's you configure and control the Game Server Watcher instance.
@@ -103,6 +104,10 @@ _The bot has no cleanup functionality, left over messages must be removed manual
If the original message created by the bot gets deleted, you need to flush the bot data to reinitialize the message.
_The bot has no cleanup functionality, leftover messages must be removed manually._
#### Flush slack data
If the original message created by the bot gets deleted, you need to flush the bot data to reinitialize the message.
_The bot has no cleanup functionality, leftover messages must be removed manually._
# Deployment
Check the wiki page for detailed instructions on [how to setup a self deploying free cloud instance at fly.io](https://github.com/a-sync/game-server-watcher/wiki/Free-hosting-via-fly.io).
The latest Pterodactyl egg can always be found here: [🥚](https://raw.githubusercontent.com/a-sync/game-server-watcher/master/egg.json)

3
TODO
View File

@@ -1,6 +1,3 @@
https://slack.dev/bolt-js/tutorial/getting-started
https://api.slack.com/apis/connections/socket
// move loop inside watcher instance
// flush game server specific (d/t) data
// response normalization: https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/query_gamedig.sh

View File

@@ -1,6 +1,6 @@
{
"name": "Game Server Watcher",
"description": "A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"description": "A simple discord/telegram/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"website": "https://github.com/a-sync/game-server-watcher",
"repository": "https://github.com/a-sync/game-server-watcher",
"logo": "https://github.com/a-sync/game-server-watcher/assets/14183614/66a8ffa8-c547-4f9c-b312-4c855da80c20",
@@ -22,6 +22,14 @@
"description": "Telegram bot token",
"required": false
},
"SLACK_BOT_TOKEN": {
"description": "Slack bot token",
"required": false
},
"SLACK_APP_TOKEN": {
"description": "Slack app token",
"required": false
},
"STEAM_WEB_API_KEY": {
"description": "Steam web API key",
"required": false

View File

@@ -45,6 +45,20 @@
"description": "Telegram bot token"
}
},
"slackBotToken": {
"type": "string",
"defaultValue": "-",
"metadata": {
"description": "Slack bot token"
}
},
"slackAppToken": {
"type": "string",
"defaultValue": "-",
"metadata": {
"description": "Slack app token"
}
},
"steamWebApiKey": {
"type": "string",
"defaultValue": "-",
@@ -131,6 +145,8 @@
"REFRESH_TIME_MINUTES": "[parameters('refreshTimeMinutes')]",
"DISCORD_BOT_TOKEN": "[if(equals('-', parameters('discordBotToken')), '', parameters('discordBotToken'))]",
"TELEGRAM_BOT_TOKEN": "[if(equals('-', parameters('telegramBotToken')), '', parameters('telegramBotToken'))]",
"SLACK_BOT_TOKEN": "[if(equals('-', parameters('slackBotToken')), '', parameters('slackBotToken'))]",
"SLACK_APP_TOKEN": "[if(equals('-', parameters('slackAppToken')), '', parameters('slackAppToken'))]",
"STEAM_WEB_API_KEY": "[if(equals('-', parameters('steamWebApiKey')), '', parameters('steamWebApiKey'))]"
}
},

View File

@@ -13,6 +13,8 @@ services:
- SECRET=secret
- DISCORD_BOT_TOKEN=
- TELEGRAM_BOT_TOKEN=
- SLACK_BOT_TOKEN=
- SLACK_APP_TOKEN=
- STEAM_WEB_API_KEY=
# env_file:
# - .env.example

View File

@@ -7,7 +7,7 @@
"exported_at": "2023-08-15T04:20:09+02:00",
"name": "Game Server Watcher",
"author": "a-sync@devs.space",
"description": "A simple discord\/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"description": "A simple discord\/telegram\/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"features": null,
"docker_images": {
"Node.js 20": "ghcr.io\/parkervcp\/yolks:nodejs_20"
@@ -74,6 +74,24 @@
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "SLACK_BOT_TOKEN",
"description": "Slack bot token",
"env_variable": "SLACK_BOT_TOKEN",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "SLACK_APP_TOKEN",
"description": "Slack app token",
"env_variable": "SLACK_APP_TOKEN",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "STEAM_WEB_API_KEY",
"description": "Steam web API key",

View File

@@ -1,7 +1,7 @@
{
"name": "game-server-watcher",
"version": "2.2.0",
"description": "A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"description": "A simple discord/telegram/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"main": "src/server",
"scripts": {
"start": "node ./dist/server.js",

View File

@@ -71,6 +71,8 @@
discord data</button>
<button type="button" class="btn btn-lg btn-info" data-api="flush/telegram">Flush
telegram data</button>
<button type="button" class="btn btn-lg btn-info" data-api="flush/slack">Flush
slack data</button>
</div>
</div>
</div>

View File

@@ -92,7 +92,7 @@ createServer(async (req, res) => {
status = 400;
re.error = 'Invalid Request';
}
} else if (reqPath[0] === 'flush' && ['servers', 'discord', 'telegram'].includes(reqPath[1])) {
} else if (reqPath[0] === 'flush' && ['servers', 'discord', 'telegram', 'slack'].includes(reqPath[1])) {
await restart(reqPath[1]);
re.message = '🗑️ ' + reqPath[1].slice(0, 1).toUpperCase() + reqPath[1].slice(1) + ' data flushed.';
} else {