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.
It's really simple, just do following steps to run from source (you need python3 & token from your bot).
git clone https://github.com/GarikFirst/PyParkingBot
- clone this repo.pip3 install -r requirements.txt
- install requirements.- specify your bot token in token key in
config.json
. - specify your bot user id in bot_owner tag in
config.json
, if you'd like to use admin commands.
python3 parking_bot.py -c CONFIG-FILE
, default (no keys specified) is config.json.- Your bot is running! You can go and check your bot in Telegram client by sending /start command.
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".
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
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