/ambabot

Bot pour vérifier les créneaux disponibles sur paris.kdmid.ru

Primary LanguagePython

AmbaBot

AmbaBot is a Python script designed to automate checking for available slots at the russian ambassy in Paris.

Functionality

The main function of AmbaBot is to handle requests identified by the AMBASSY_REQUEST_NUMBER.

The bot will:

  • Connect to https://paris.kdmid.ru with your AMBASSY_REQUEST_NUMBER and AMBASSY_PROTECTION_CODE
  • solve the captcha using aws textract
  • extract the current status of your request
  • if there are free slots, send an email to EMAIL_TO

This project contains a Python AWS Lambda function and Terraform configuration for deploying it.

Prerequisites

  • AWS account
  • Python 3.10
  • Pipenv
  • Terraform

Local Development

  1. Install the Python dependencies:
pipenv install
  1. Run the Python script locally:
pipenv run ambabot

Deployment

  1. Build the Lambda deployment package:
./build.sh
  1. Initialize Terraform:
terraform init
  1. Apply the Terraform configuration:
terraform apply

Environment Variables

Create a .env file in the project root with the following variables:

AWS_REGION=your_aws_region
AWS_PROFILE=your_aws_profile

#  Номер заявки
AMBASSY_REQUEST_NUMBER=999999

#  Защитный код 
AMBASSY_PROTECTION_CODE=XXXXXXXX

LOG_LEVEL=DEBUG
EMAIL_TO=contact@ophir.dev
EMAIL_FROM=contact@ophir.dev

Logs

The logs are available in CloudWatch, in the log group /aws/lambda/ambabot. To view the logs, run the following command:

aws logs get-log-events --log-group-name /aws/lambda/ambabot --log-stream-name $(aws logs describe-log-streams --log-group-name /aws/lambda/ambabot --limit 1 --query 'logStreams[0].logStreamName' --output text)