-
Notifications
You must be signed in to change notification settings - Fork 10
Initial project setup
-
Grab the code at https://github.com/UncleVasya/Dota2-EU-Ladder
-
Install python 3.7.1 or newer: https://www.python.org/downloads/release/python-379/
-
Install virtual environments manager for python:
pip install virtualenv
- In the project folder create virtualenv:
virtualenv .virtualenv
This should create a .virtualenv folder inside project folder.
- Activate virtualenv:
.virtualenv\Scripts\activate.bat
If successful, you will have (.virtualenv) at the start of your command line.
All commands to work with project/bots/website should be ran from virtualenv.
- Install dependencies for the project:
pip install -r requirements.txt
- Create a database:
python manage.py migrate
Now you should have a db.sqlite3 file in the project folder.
- Try to run inhouse website:
python manage.py runserver
This will give you the link, you can open it to see if it works.
-
Keep that cmd window running, open a new one. Don't forget to activate virtualenv.
-
In the new cmd let's create an admin user:
python manage.py createsuperuser
Now you are able to login to http://localhost:8000/admin
Nothing to do there yet.
- Create a few steam accounts for the bot. Bot logins and passwords should be the same, just add a number after each one. For example
login: clarity_ih1, password: clarity_potion1
login: clarity_ih2, password: clarity_potion2
login: clarity_ih3, password: clarity_potion3
3 should be enough, at least for the start.
-
Create a discord bot account here: https://discord.com/developers/applications Invite it to your server.
-
Add bots credentials. Open
.virtualenv/Scripts/activate.batin a text editor. Add these lines afterset ...line:
set "BOT_LOGIN=***"
set "BOT_PASSWORD=***"
set "LOBBY_PASSWORD=***"
set "LEAGUE_ID=***"
set "DISCORD_BOT_TOKEN=***"
Replace all *** with actual values.
- if you don't have a dota ticket for the league you can put 0 there.
- bot login should be a part before the number. So like
clarity_ih. - you can get discord token on
Bottab of your discord bot page.
- re-activate virtualenv for it to pick up new environment variables:
deactivate
.virtualenv/Scripts/activate.bat
- Setup ih channels on discord. Bot needs 5 channels:
-
#inhouse-queue- main channel for players to join, leave and view queues -
#inhouse-chat- players can use bot commands there. -
#inhouse-polls- outdated, but I was too lazy to remove it from the code; -
#open-queue- admin channel for the open queue (here admins can use commands to remove or add players to the queue); -
#elite-queue- admin channel for the elite queue;
Last 3 channels can be hidden from non-admins.
- Now we need to let bot know about our discord channels.
In website admin panel (localhost:8000/admin) there is Discord Channels setting. Add ids of discord channels.
To see discord channel id, turn on developer mode in discord settings => Appearance => Advanced (scroll to the bottom of the page). Now you can click right mouse button on every thing in discord to see its id.
- Add discord queue channels to admin panel. Create a QueueChannel object for both queue channels: https://images2.imgbox.com/31/4c/ZOhWbRQE_o.png
Also when creating bot steam accounts you have to disable 2FA for each of them.
- Let's try and start our discord bot:
python manage.py discord_bot
If all good, it should respond to commands. Try !register in inhouse-chat.
- Keep that cmd window running, open a new one and let's start a dota bot:
python manage.py dota_bot -n 2
n is the number of bots.
- Random tips:
- you can change dota lobby name in admin panel => Ladder settings;
- after you registered as a player in inhouse-chat, you can go to admin => Players => Crispy Bacon and checkmark bot access to give yourself admin perms for discord and dota bots.
- as you see, you'll always have cmd windows open with scripts running: website, discord bot, dota bot.
This instruction might look long and scary but once you started doing steps you will see that it's not that difficult.