{"id":20608718,"url":"https://github.com/roataway/telegram-bot","last_synced_at":"2025-04-15T04:23:19.918Z","repository":{"id":53533092,"uuid":"173439077","full_name":"roataway/telegram-bot","owner":"roataway","description":"A Telegram bot for reporting ETAs for public transport in Chișinău, Moldova","archived":false,"fork":false,"pushed_at":"2022-12-08T04:54:50.000Z","size":950,"stargazers_count":13,"open_issues_count":9,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T15:51:47.770Z","etag":null,"topics":["csv","moldova","mqtt","public-transport","telegram"],"latest_commit_sha":null,"homepage":"http://t.me/roataway_bot","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roataway.png","metadata":{"files":{"readme":"readme.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-02T11:22:22.000Z","updated_at":"2024-09-28T15:20:23.000Z","dependencies_parsed_at":"2023-01-24T11:05:12.072Z","dependency_job_id":null,"html_url":"https://github.com/roataway/telegram-bot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roataway%2Ftelegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roataway%2Ftelegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roataway%2Ftelegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roataway%2Ftelegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roataway","download_url":"https://codeload.github.com/roataway/telegram-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004638,"owners_count":21196913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","moldova","mqtt","public-transport","telegram"],"created_at":"2024-11-16T10:11:29.164Z","updated_at":"2025-04-15T04:23:19.901Z","avatar_url":"https://github.com/roataway.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://travis-ci.org/roataway/telegram-bot.svg?branch=master\n    :target: https://travis-ci.org/roataway/telegram-bot\n\n.. image:: https://img.shields.io/github/license/roataway/telegram-bot.svg\n    :alt: GitHub license\n    :target: https://github.com/roataway/telegram-bot/blob/master/LICENSE\n\n.. image:: https://img.shields.io/badge/zulip-join_developer_chat-blue.svg\n    :alt: Chat with the developers on Zulip\n    :target: https://roataway.zulipchat.com/\n\n.. image:: https://img.shields.io/badge/telegram-use%20chat%20bot-blue.svg?logo=telegram\n    :alt: Use the chat bot on Telegram\n    :target: http://t.me/roataway_bot\n\n\nOverview\n========\n\nA Telegram bot to provide ETA for public transport in Chișinău. A live instance is available at http://t.me/roataway_bot. \n\nThe bot is written in Python and it was tested with 3.6, though earlier versions will work too, if you install the backported version of the ``dataclasses`` module.\n\nDiscussions and development support\n===================================\n\nHead to  to ask questions about the code and its structure, suggest new features or ask for tips on how to get started with running your own copy of the bot.\n\n\n\n\nHow to run it\n=============\n\nPrerequisites\n-------------\n\n#. Talk to @BotFather to register your bot and get a token, as described here: https://core.telegram.org/bots#6-botfather\n#. Make a copy of ``res/config-sample.yaml`` to your own config file, e.g. ``config-development.yaml``, supplying the required information in the file\n#. Replicate the environment using ``virtualenv`` or ``pipenv``, as described below\n#. When done, run it with ``python main.py res/config-development.yaml``\n\nThe credentials as well as the server connection details are deliberately not a part of this repository. They can be found on rtec.dekart.com/infodash. The ability to figure it out on your own is the qualification barrier for getting started with this bot. Note that ``infodash`` uses WebSTOMP, rather than MQTT; however, the credentials are the same.\n\n\nVirtualenv\n----------\n\n#. Create the virtualenv ``virtualenv venv-infopanel-chatbot`` to install the dependencies in it\n#. Activate the venv with ``source venv-infopanel-chatbot/bin/activate``\n#. Install the dependencies with ``pip install -r requirements.txt``\n\n\nPipenv\n------\n\n#. Install pipenv ``pip install pipenv``\n#. Then run ``pipenv install --dev``. It will deal automatically with the venv creation and dependecy installing\n\n\nTechnical details\n=================\n\nThe bot uses MQTT to subscribe to updates related to ETAs and the locations of trolleybuses.\n\n\nMessage formats\n---------------\n\nThere are 2 types of messages that are received via MQTT at the moment, all payloads are in JSON format:\n\n1. ETA updates that contain a list of estimates for the next couple of incoming transports. Such messages arrive in batches, approximately twice per minute:\n::\n\n  {\n    \"station_id\": 17,    # the station ID to which the prediction refers\n    \"name\": \"str. 31 August - sosire\"   # the name of the station\n    \"eta\": {\n      \"30\": [            # the route number to which the prediction refers\n        [3, \"3898\"],     # 3 minutes until board \"3898\" arrives\n        [22, \"3913\"]     # 22 minutes until board \"3913\" arrives\n      ]\n    },\n  }\n\n2. Transport coordinates, which contain data about the last known location and speed of a given trolleybus. These are sent every ~6s:\n::\n\n  {\n  \"rtu_id\": \"004\",  # internal identifier in the backend, you can ignore it\n  \"board\": \"3900\",  # the board number, it is written on the trolleybuses themselves\n  \"route\": \"30\",    # human-readable name of route (may contain letters)\n  \"lat\": \"47.027388\",\n  \"lon\": \"28.885762\",\n  \"dir\": \"0\",       # direction of motion, measured in degrees. Note that the\n                    # coordinate system is _not_ cartesian, but the one you see\n                    # on a compass. North is up at 0, East is right at 90,\n                    # South is down at 180, West is right, at 270 degrees.\n  \"speed\": 0,       # in km/h\n  }\n\nThe JSON may contain other keys, do not rely on them if they're not documented.\n\n\n\nStation details\n---------------\n\nThe information about supported stations is loaded from CSV files located in ``res/routes``, the format is ``station_id, station_order, station_name, direction``. The identifiers are generated by the RTEC database, we just have to assume they are constants.\n\nThe resources in ``res/routes/drafts`` are treated as work in progress, and are ignored when the data are loaded.\n\n\nHow to contribute\n=================\n\nFor historical reasons, the code, comments and the instructions are written in English. Ideally, you should follow the same conventions. When opening issues, you can describe them in Romanian or Russian, besides English.\n\nIf you made any changes, send a pull request, explaining what you've done and why you've done it.\n\nIf you need any help, just ask.\n\nBefore commit\n-------------\n\n1. Run ``make autoformat`` to format all ``.py`` files\n2. Run ``make verify`` and examine the output, looking for issues that need to be addressed\n\n\nBuilding the readme\n-------------------\n\n#. Install ``rst2html`` (on Debian and its derivatives: ``sudo apt install docutils-common``).\n#. Run ``rst2html readme.rst \u003e readme.html`` to render the output and make sure it looks good.\n\n\nBot configuration\n=================\n\nTo set a lit of commands, go to @BotFather and send ``/setcommands`` for the bot, with the following data::\n\n    prognosis - Vezi prognoza pentru o rută\n    feedback - Transmite sugestiile sau întrebările tale\n    help - Află cum îți pot fi de folos\n    about - Despre mine\n\nNotes on obtaining ``feedback_chat_id``, it is a unique chat identifier, which you need if you want the bot to post messages somewhere. You can get this number using several methods:\n\n#. Go to ``https://api.telegram.org/bot\u003ctoken\u003e/getUpdates`` and look around\n#. Or add ``@RawDataBot`` to the group or the channel in question, and watch its debug output as you post a message. Don't forget to kick it out of the group once you've got the number.\n\n\nContributors and credits\n========================\n\n* Roata wăy relies on an external data stream. None of the features of this bot would work without the backend and the hardware designed for deployment on the trolleybuses themselves.\n* The production bot instance is hosted on a server generously provided by ``name withheld``.\n* Initial proof of concept written by ``name withheld #2``.\n* Others listed here: https://github.com/roataway/telegram-bot/graphs/contributors\n* How about 👉 **you** 👈?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froataway%2Ftelegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froataway%2Ftelegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froataway%2Ftelegram-bot/lists"}