The Firebears Slack Bot was invented to force people to scout without telling them, and if they are unable to complete thir scouting duties, they lose points.
At the start, it gets all the names form the .env
file's General Channel IDs members list.
Firstly download all the code and open up or create a .env
file in the root directory IE /slackbot/.env
and copy all below and just insert your API keys.
SLACK_TOKEN= Slack API Token
GeneralChannelID= The Channel ID For The Main Chat / General Chat
ScoutingChannelID= The Channel ID For The Secondary Chat / The Scouting Only Chat
TBA_KEY= The Key For The Blue Allience
TEAM_KEY= Your Team Number IE 2846
SITELINK= The Link For The Site IE https://google.com
SERVER_IP= The IP For The Server Hosting This BOT IE: 0.0.0.0
BAD_BEHAVIOR= Points Lost On Scouting
GOOD_BEHAVIOR= Points Gained On Scouting
WIN= Points Lost To Drive Team When Losing A Match
LOSS= Points Gained To Drive Team When Losing A Match
DriveTeamMembers="DRIVE MEMBER A:DRIVE MEMBER B:DRIVE MEMBER C"
For each Drive Team Member add a
:
for the program to split / indicate the persons name
MAKE SURE YOU CREATE A scouters.json
FILE!!
Example Scouters JSON File
{
"A": [
"NAME","NAME"
],
"B": [
"NAME","NAME"
]
}
Open The GoogleCloudTerminal or SSH into it.
Then Download and install NodeJS and NPM by running
sudo apt install nodejs npm
You Need GoogleCloud Installed. You Can Download Here
When Uploading Code, Delete
./node_modules
as the files are too big and is better to runnpm install
on the server later
ALSO MAKE SURE THAT YOUR COMPUTE ENGINE IS RUNNING!
When You Have Fully Working Code and Created A Valid Google Compute Engine, You can run
gcloud compute scp --recurse ./ USERNAME@VM_INSTANCE:
To Send All Files In The Current Folder ./*
To The Base Folder Of GCP
Change USERNAME to your login name Change VM_INSTANCE to the name of the Virtual Machine
In order for the Server to be enabled and to send data over to the server (GCP Compute). We need to enable specific Firewall Settings.
- Open The Firewall Settings In GCP Console
- Open GCP Here
- Open VPC Network In GCP
- Go To The Firewall Settings
- In The Firewalls Add New Rule
- Enter A Name And Desc
- For Target Enter 'Specified target tags'
- Enable TCP & UDP and type port
3000
Once in the server console just run npm run dev
and it will start the server
Once you see a progress bar you know it will work
Problem is when restarting / when the server crashes the file wont re-start
using PM2 will mitigate the problem where if the server crashes
PM2 will restart it for us.
On the server run npm install pm2
Then run npx pm2 index.js