Giter VIP home page Giter VIP logo

asvz-enroller's Introduction

ASVZ Enroller

The asvz enroller is a Telegram-based ASVZ bot that signs you up for your ASVZ sports lessons as soon as registration opens. You send it links to lessons via Telegram and it will communicate with you as soon as you are enrolled. If a class is already full, it will periodically check and try to get you a spot.

The application automatically schedules enrolment jobs (done with selenium) and can be deployed easily using Docker on any host.

The application consists of two main parts. First, each user goes to a web interface that allows them to save their ASVZ credentials and link their Telegram account. Once this is done, interaction is only via Telegram. The web interface guides the user through all the details.

Note: The enroller (primarily the selenium code) is based on https://github.com/fbuetler/asvz-bot

Installation

To run this application you need to have Docker installed. Further you need to have a telegram bot API key.

Clone this repository and create a config.yaml file in the root and fill it with the required information. See config_example.yaml for details on how the file should be structured. See below for details on how to add users.

To start the containers simply run:

docker-compose up --build -d

By default this will expose the web interface on port 5090 on localhost. Modify the docker-compose.yaml file to change the port binding.

Creating users

Only the host can add new users. Use the admin.py script to create/reset/delete any users.

To create a user run:

python admin.py -u USERNAME

The script will automatically create a password for this user. The user can't change it. These login credentials are for the web interface that will allow him to store his ASVZ login credentials and connect to his telegram account.

If you want to reset a user run:

python admin.py -u USERNAME -r

This will delete any associated data and create a new password.

To delete a user run:

python admin.py -u USERNAME -d

Broadcasting

It might be of interest to broadcast messages to all users. This is mainly intended to announce downtime or similar things.

python broadcast.py -m "A test message"

This will send a message from the bot to all users that have connected a telegram account.

Data privacy

You should be aware that the application must store the ASVZ credentials of all users locally. So that the passwords are not completely unencrypted in the database, they are encrypted with a symmetric encryption. But the key is defined in the config and lies on the host machine as well. Primarily intended such that the host does not accidently reads passwords when analysing the database in case of bugs.

asvz-enroller's People

Contributors

jkminder avatar

Stargazers

 avatar  avatar

Watchers

 avatar

asvz-enroller's Issues

Wait for enrollment: Refactoring

Currently for each enroll job a process is spawned and when the lesson is full the process keeps checking. This is highly inefficient. We should refactor this. Issue relates to #1. This includes the following

  • If a lesson is full, the user should be notified.
  • The enroll job should be put back into the job queue. This way the user still sees it with /jobs. How can we reactivate it when there are free places (are there hooks in apscheduler? set the datetime of the job directly once it should be spawned again?)
  • A dedicated "check if there are places avail" worker should be spawned whenever there are full lessons. It should loop regularly through all full lessons -> we need a full lessons queue (note that this must be process safe, somewhere in sharedmem). This also needs to be persisted/or whenever the app is started again all "currently full" jobs must be rerun such that they are placed back in the "full lesson" queue. If the worker notices that there are free places, the enrolment job should be notified and respawn. Tbh maybe a thread would be enough here. Not expecting big user base.
  • Cleanup the enroller.py file a bit, very cluttered.

Crash of selenium driver

Selenium driver crashes. Probably due to memory constraints because of multiple instantiated drivers. Several options should be explored:

Create user issue with relative imports

The create user script fails because of relative imports and how only the src folder is copied into the container. Fix somehow. Easiest is probably to just reinstate the flask app with the db directly in the create_user script. Maybe would be clean to then export the app config to a json/yaml.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.