Leetcode Discord Bot
Sends daily problem to a Discord channel. Tested on Python 3.10.
Installation
-
Setup a Python environment
$ python -m venv env
-
In VSCode, make sure you set this environment as the default Python interpreter. This can also be done by pressing
cmd/ctrl + shift + P
and typing ">Python: Select Interpreter", then selecting the newly created environment./env/bin/python
-
Enter the environment if you haven't already
# macOS $ source env/bin/activate # windows $ .\env\Scripts\activate
-
Install requirements
$ pip install -r requirements.txt
-
Rename
.env.sample
to.env
and fill out the required credentials -
Run bot.py for the discord bot, or webhook.py to send a webhook. The webhook.py script can be used in a cron job.
Setting up Terraform and AWS
-
Create a unique bucket name by going to
vars.tf
and updating the default value for thetf-bucket-name
variable. -
Update to your bucket name in
tfstate.tf
under theterraform
block at the bottom of the file. -
Comment out the
terraform
block all the way at the bottom of thetfstate.tf
file. This is because Terraform expects the S3 bucket to be already created prior to initializing it. -
Initialize terraform
cd terraform/ terraform init
-
Apply the terraform code
terraform apply
-
Uncomment the
terraform
block that you commented in step 3. -
Run apply again to create the S3 bucket to hold the terraform state
terraform apply
Deploying to AWS
-
Go to AWS/ECR
-
Select the
leetbot
repo -
On the top, click
View push commands
and follow the commands to upload the Leetbot docker image to ECR