Giter Site home page Giter Site logo

t0mer / wazy Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 3.0 69 KB

Wazy a python based telegram bot, that helps us checking travel times using Waze route calculation.

License: Apache License 2.0

Python 98.36% Dockerfile 1.64%
bot fastapi telegram telegram-bot traffic waze

wazy's Introduction

Wazy

Wazy is a bot based on Telegram bot that allows checking travel times using Waze.

wazy.mp4

Features

  • Check current route travel time.
  • Set interval for route travel time checks.
  • Get waze navigation url that opens in the application.
  • Set maximum travel time and get warning is the travel time exceeds the maximum.
  • Configure default rout.
  • Configure list of routes.
  • Configure addresse.
  • Rest API to integrate with other applications/systems.

Components and Frameworks used in Wazy

Installation

Before we can start working with Wazy, we need to create a new telegram bot.

Create Telegram bot

How to Create a New Bot for Telegram Open Telegram messenger, sign in to your account or create a new one.

Enter @Botfather in the search tab and choose this bot (Official Telegram bots have a blue checkmark beside their name.)

@Botfather

Click “Start” to activate BotFather bot.

@start

In response, you receive a list of commands to manage bots. Choose or type the /newbot command and send it.

@newbot

Choose a name for your bot — your subscribers will see it in the conversation. And choose a username for your bot — the bot can be found by its username in searches. The username must be unique and end with the word “bot.”

@username

After you choose a suitable name for your bot — the bot is created. You will receive a message with a link to your bot t.me/<bot_username>, recommendations to set up a profile picture, description, and a list of commands to manage your new bot.

@bot_username

Docker

Wazy is a docker based application that can be installed using docker compose:

version: "3.6"
services:
  wazy:
    image: techblog/wazy
    container_name: wazy
    restart: always
    ports:
      - "8081:8081"
    environment:
      - LOG_LEVEL=DEBUG
    volumes:
      - ./wazy:/app/config

Environment

  • LOG_LEVEL - Optional valuse are: DEBUG (default), INFO, ERROR

Volumes

In order to adapt Wazy to the needs of the user, several things must be defined such as addresses, routes and Telegram API key. Inside the config folder there is a file called config.ini where you can define the necessary parameters for the bot to work.

Ports

In order to enable integration with other systems, Wazy is also accessible via Rest API. In order to allow access, the port must be defined in the docker-compose file. The default port is 8081.

Wazy configuration

Wazy can be easily using the config.ini file. by default this file is empty and created on first system start. you can also copy the following content and to new file inside the config folder prior to the containr startup.

[Telegram]
bot.token=
bot.allowedid=
bot.welcome.message=Hi, my name is Voicy
bot.enabled=False

[WAZE]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.region=IL
route.start_address=
route.end_address=
route.max_duration=20
routes=['work2home','home2work']
address=['home','work','school','parents']

[work2home]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.start_address=
route.end_address=
rout.max_duration=20

[home2work]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.start_address=
route.end_address=
rout.max_duration=20

[ADRESSES]
address.home=
address.work=
address.parents=
address.school=

Sections:

  • Telegram:

    • bot.token: Bot token generated in installation section.
    • bot.welcome.message: Bot welcome message when clicking the start command.
    • bot.enabled: Enables or Disables the bot. default is set to disabled.
  • Waze:

    • route.avoid_toll_roads: When true, the waze route calculator will avoid toll roads.
    • route.avoid_subscription_roads: same as above but for subscription roads.
    • route.start_address & route.end_address: setting the default toute to check.
    • routes: List of routes that can be monitored.
    • address: List of addresses that can be set as start and end for routes.
  • work2home and home2work - example of pre-configured routes:

  • ADDRESSES: Pre-configured addresses that can be set as route start and end points.

Rest API

As I mentioned, working with Wazy is also possible using the Rest API. API documentation can be found by adding /docs to the server address. For example http://wazy:8081/docs.

Wazy rest API

  • "/route/get": Get travel time for route between addtesses:

    • from_address: can be any addres, like "Raanana, Israel"
    • to_address: can be any address, like "Tel aviv, Israel"
  • "/route/default": Get travel time for default route that was configured in the config.ini file.

  • "/route/byname" : Get travel time for route by it's name.

  • "/route/locations": Get travel time between to addresses taken the configuration file ander [ADDRESSES] section.

wazy's People

Contributors

atlanteh avatar dimagoltsman avatar t0mer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.