FastestMolasses / LeetcodeDiscordBot

Sends daily problem to a Discord channel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Leetcode Discord Bot

Sends daily problem to a Discord channel. Tested on Python 3.10.

python

Installation

  1. Setup a Python environment

    $ python -m venv env
  2. 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

  3. Enter the environment if you haven't already

    # macOS
    $ source env/bin/activate
    # windows
    $ .\env\Scripts\activate
  4. Install requirements

    $ pip install -r requirements.txt
  5. Rename .env.sample to .env and fill out the required credentials

  6. 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

  1. Create a unique bucket name by going to vars.tf and updating the default value for the tf-bucket-name variable.

  2. Update to your bucket name in tfstate.tf under the terraform block at the bottom of the file.

  3. Comment out the terraform block all the way at the bottom of the tfstate.tf file. This is because Terraform expects the S3 bucket to be already created prior to initializing it.

  4. Initialize terraform

    cd terraform/
    terraform init
  5. Apply the terraform code

    terraform apply
  6. Uncomment the terraform block that you commented in step 3.

  7. Run apply again to create the S3 bucket to hold the terraform state

    terraform apply

Deploying to AWS

  1. Go to AWS/ECR

  2. Select the leetbot repo

  3. On the top, click View push commands and follow the commands to upload the Leetbot docker image to ECR

About

Sends daily problem to a Discord channel.


Languages

Language:Python 47.4%Language:HCL 45.0%Language:Dockerfile 6.0%Language:Makefile 1.6%