Code Monkey home page Code Monkey logo

pyparkingbot's Introduction

PyParkingBot

Simple telegram bot on python3 for parking booking and some statistics about parking use.

This bot uses the python telegram bot framework to make Telegram API calls.

All messages are in russian, but you can adapt it with no effort, there about 10 of them.

Installation

Install

It's really simple, just do following steps to run from source (you need python3 & token from your bot).

  1. git clone https://github.com/GarikFirst/PyParkingBot - clone this repo.
  2. pip3 install -r requirements.txt - install requirements.
  3. specify your bot token in token key in config.json.
  4. specify your bot user id in bot_owner tag in config.json, if you'd like to use admin commands.

Launch the bot

  1. python3 parking_bot.py -c CONFIG-FILE, default (no keys specified) is config.json.
  2. Your bot is running! You can go and check your bot in Telegram client by sending /start command.

Usage

Logic is really simple - each place has three states:

  • free
  • reserved
  • occupied

and can change state between these possible states (free -> reserved -> occupied -> free -> ...).

User can make reserve for place (and cancel if necessary), than occupy the place, then free the place. Since place occupied no other user can take this place.

Also, anybody have an option to free all parking if at least one of the places is not free (for those, who forget to check out from parking in the evening).

There is some statistics (like top usage of the places, persons, weekdays, etc) about usage available in statistics "menu".

Admin commands

This bot has several admin commands.

  • /logs n (n can be omitted) - bot will reply with message that contains n lines from logfile, if n is omitted, than log_length from config file number of lines
  • /whitelist - toggle whitelist mode on and of. If whitelist mode is on, bot will reply to users that already using the bot (users in users.json)
  • get_stats - bot will reply with message that contains statistics in json format (not with file)
  • set_stats {json} - overwrite current statistics with provided json formated message (not a file) as argument

Config options

Option Description
owner_id bot admin user_id
places list of desired parking places
token bot token
whitelist whitelist mode on start
logging/log_file filename for logfile
logging/log_length default log length for /logs
users_file filename for users file
data_file_prefix prefix for data files

Copyright © 2021 Igor Bulekov

pyparkingbot's People

Contributors

garikfirst avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyparkingbot's Issues

Don't run app

root@Ubuntu-1804-bionic-64-minimal ~/PyParkingBot # python3 -c config-sample.json Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'config' is not defined

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.