Giter Site home page Giter Site logo

autobot's Introduction

Autobot: A Telegram bot for car allocation

Local testing instructions

The following instructions are for Linux machines, they must be modified accordingly for Windows and Mac.

Preparation

  1. Prerequisites: you need a local install of Python 3, together with the pip package manager and virtualenv;
  2. Install the Google Cloud SDK outside of the project directory (if you chose to not add the gcloud executable in the PATH, substitute it in the rest of the documentation with <PATH_TO_GCLOUD_SDK>/bin/gcloud);
  3. Install the Python App Engine extensions: gcloud components install app-engine-python
  4. Install the Datastore emulator: gcloud components install cloud-datastore-emulator
  5. From the shell, while inside the project directory, create a new Python virtual environment: virtualenv --python python3 env. The following commands must be executed from the same shell without changing location.
  6. Activate the new environment: source env/bin/activate
  7. Install the runtime dependencies: pip install -r requirements.txt
  8. Create a config.ini file with the configuration. If you do not plan to deploy the app, you can use placeholder values:
    [DEFAULT]
    telegram_token = 000000000:0
    hook_address = /
    bot_url = 

Starting of a local testing session

  1. Run the datastore emulator: gcloud beta emulators datastore start --no-store-on-disk (omit the --no-store-on-disk part if you want the datastore content to persist across the emulator restarts)
  2. In another shell, initialize the needed environment variables: $(gcloud beta emulators datastore env-init). The following commands must be executed inside the shell where this command has been executed.
  3. Activate the Python virtual environment: source env/bin/activate
  4. If new dependencies are needed, install them: pip install -r requirements.txt
  5. Run the application: python main.py

The code executed while in debugging mode is inside the if __name__ == '__main__': block. Remember that no connection to Telegram is possible while running locally (actually, that is possible, but you have to change a portion of the code and register a testing bot in Telegram), therefore, you cannot call command handlers directly. An exception is valid for simple handlers, where the mock update object is able to mimick the necessary functionality of Telegram. In this case, the answer will be printed to screen, instead of being sent to Telegram servers.

Deployment

Preparation

  1. Perform the preparation steps for local testing
  2. In the project folder, activate the Python virtual environment: source env/bin/activate
  3. Install a local copy of the runtime dependencies: pip install -t lib -r requirements.txt

Deploy a new version of the app

  1. If new dependencies have been added from the last deployment, install them from inside the project folder: pip install -t lib -r requirements.txt
  2. Deploy the app: gcloud app deploy

autobot's People

Contributors

danileo avatar electricant avatar mychele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

autobot's Issues

Make /status persistent across calls

Whenever a /status command is executed, a new random pool of cars is extracted.
Make such pool persistent across calls until the stored preferences change.

Create Readme

Create a README.md file in the project to provide clarity and accessibility to the project

Add time option to /auto and /posto command

Given that some people prefer to have launch early, while others cannot stand eating before 13.00, I suggest to add a "time" option to the /auto and /posto commands ๐Ÿ˜›

Create a /reset command

The /reset command should delete all the preferences stored in the database (for the given chat, see #5).

Provide a improved /status command

Have a /status command that shows a quick summary of the requests. Something like:

Posti auto disponibili: N (N = sum n_i where n_i number of places for car i)
Posti auto richiesti: M
Bici: P

/macchinaobici /biciomacchina are pretty ambiguous let's decide how to count them.

If N > 0 car seat association (FIFO) should be shown. It could be printed out like this:

Macchina 0: DRIVER-0, passenger-01, ..., passenger-0n
...
Macchina N: DRIVER-N, passenger-N1, ..., passenger-Nn

Just something off the top of my head. Wrote it here as a reference. To be discussed.

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.