Skip to main content

turbine-troubleshooter-bot

A Telegram bot for field technicians: search fault codes and spare parts, look up turbine info and IO board pin-outs, and browse reference content (text, documents, photos). Access is by approval, with admins who can add and edit codes and parts.

It is a Python package that a host application installs and starts, or that runs on its own. All site-specific content and documents are supplied by the host at runtime; nothing private lives in this repo.

Install

pip install turbine-troubleshooter-bot

The package installs as turbine-troubleshooter-bot and imports as turbine_troubleshooter.

Use

Inside a host application:

from turbine_troubleshooter import start_troubleshooter_bot, stop_troubleshooter_bot

await start_troubleshooter_bot(share_with=main_application, files_dir=Path("media"))
...
await stop_troubleshooter_bot()

share_with is optional: pass the host's Application when the host shows the troubleshooter menus too, so both bots use the same loaded codes, parts and users.

On its own (reads a .env in the current folder):

python -m turbine_troubleshooter

Standalone also uses TROUBLESHOOTER_FILES_DIR (default media) and TROUBLESHOOTER_SENTRY_DSN (Sentry is off when unset).

The settings below are read from the environment; any keyword passed to start_troubleshooter_bot() overrides the environment.

Setting Environment variable Purpose
name TROUBLESHOOTER_NAME Shown in menus and messages ("name Bot"). Default Troubleshooter
wtg_prefix TROUBLESHOOTER_WTG_PREFIX Prefix for turbine IDs, e.g. WT turns A5 into WTA05
token TROUBLESHOOTER_BOT_TOKEN Bot token from @BotFather (see Create your Telegram bot)
owner_id TROUBLESHOOTER_OWNER_ID Your Telegram user ID; the owner approves access and admins (how to find it)
alerts_chat_id TROUBLESHOOTER_ALERTS_CHAT_ID Group or channel for new-user, access-request, suggestion and change notifications. Defaults to the owner's private chat (setting one up)
timezone TROUBLESHOOTER_TIMEZONE Used for edit timestamps and weather. Default Europe/London
cefas_buoy TROUBLESHOOTER_CEFAS_BUOY Cefas WaveNet buoy ID for sea state; enables 🌦 Weather
windquest_location TROUBLESHOOTER_WINDQUEST_LOCATION Preferred WindQuest forecast location (falls back to the main location)
windquest_api_key, windquest_api_token WINDQUEST_API_KEY, WINDQUEST_API_TOKEN WindQuest credentials for wind, lightning and tides
files_dir — Folder that file: references in the content resolve against
content — Fallback content when the database has none (see below)
noise_filters — Error messages to ignore. Defaults to common network blips

Database

MySQL, via TROUBLESHOOTER_DB_URL, e.g. mysql://user:pass@host:3306/db. It's required: the bot won't start without it, and never falls back to a host's own JAWSDB_URL, so it can't end up writing to the host's database. Tables are created on first start: codes, parts, users, one table per IO board, content, settings, requests (access and admin requests waiting for the owner) and suggestions (content suggestions waiting for the owner).

Content suggestions

Approved users can suggest a note, a PDF or photo, or a file with text, from 📝 Suggest Content on the main menu. Text sent with a file is shown as its caption, so it's limited to Telegram's 1024 characters. It waits in Admin Panel → 📝 Suggestions until the owner approves or rejects it. Nothing reaches other users before that.

  • Text goes live as soon as it's approved: the bot writes it into the content table.
  • A PDF or photo adds its menu item straight away, pointing at a file: path in files_dir, and the bot sends the owner the file with the exact path to save it as. Until the file is uploaded, the item says the document isn't available. Files go in the host's files folder, as with any other document.

PDFs and photos can only be sent to the troubleshooter bot itself, up to 20 MB. A host showing the menus through share_with takes text suggestions only.

settings holds the owner's Notify Users toggles (notify_added, notify_edited, notify_deleted; on unless a row says 0), set from Admin Panel → 🔔 Notify Users. When one is off, that kind of code or part change is only sent to admins.

Content

The menus, turbine map, IO boards and part-search hints are loaded from the content table: one row per item (MODULES_MAP, WTG_MAP, IO_BOARDS, PART_ACCESSORIES), stored as JSON text. Documents and photos are referenced as file:<path relative to files_dir>. See turbine_troubleshooter/example_content.py for the shape.

Create your Telegram bot

Every copy of the bot needs its own bot account. A token can only be used by one running bot at a time, so two copies sharing one token get "Conflict" errors.

  1. In Telegram, open @BotFather and send /newbot.
  2. Give it a display name, for example Site Troubleshooter.
  3. Give it a username. It must be unique and end in bot, for example site_troubleshooter_bot.
  4. BotFather replies with a token that looks like 123456789:AAH.... Put it in TROUBLESHOOTER_BOT_TOKEN.

The token is a password: anyone who has it controls the bot. Never commit it or paste it in an issue. If it leaks, send /revoke to BotFather to get a new one.

Your Telegram user ID

The owner is set by user ID, not username. Message @userinfobot and it replies with your ID, a number like 123456789. Put it in TROUBLESHOOTER_OWNER_ID.

An alerts group or channel

Notifications go to the owner's private chat unless you set TROUBLESHOOTER_ALERTS_CHAT_ID. To send them to a group or channel instead:

  1. Add the bot to the group. For a channel, add it as an admin that can post messages; it can't post in a channel otherwise.
  2. Find the chat's ID. With the bot stopped, open https://api.telegram.org/bot<your token>/getUpdates in a browser and look for "chat":{"id":-100... from adding the bot. If the list is empty, remove the bot and add it again, then reload.
  3. Put the ID, including the minus sign, in TROUBLESHOOTER_ALERTS_CHAT_ID.

If the host's own bot is also in that group or channel, it receives the troubleshooter's alerts and edits as updates too. Make sure it ignores channel posts and edited channel posts (~filters.UpdateType.CHANNEL_POSTS in python-telegram-bot).

Run it yourself

You need Python 3.12+, a MySQL database and your own test bot (Create your Telegram bot). Your copy uses its own bot and database, so it never touches anyone else's.

Any MySQL works (a local install, or a free hosted one such as JawsDB). The docker run line below is the quickest way if you have Docker Desktop installed; skip it otherwise.

git clone https://github.com/Adz1DoubleD/turbine-troubleshooter-bot
cd turbine-troubleshooter-bot
python -m venv .venv
.venv\Scripts\activate            # Mac/Linux: source .venv/bin/activate
pip install -e ".[dev]"

docker run -d --name ts-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=dev -e MYSQL_DATABASE=ts mysql:8

cp .env.example .env               # Windows: copy .env.example .env

In .env, set these three (the bot refuses to start and lists any that are missing):

  • TROUBLESHOOTER_BOT_TOKEN: your test bot's token from @BotFather.
  • TROUBLESHOOTER_OWNER_ID: your Telegram user ID.
  • TROUBLESHOOTER_DB_URL: your MySQL database.

Everything else is optional. Access requests, content suggestions and change notices go to TROUBLESHOOTER_ALERTS_CHAT_ID, or to the owner when it isn't set. Then:

python -m turbine_troubleshooter

Open your test bot in Telegram and send /start. As the owner you get the admin panel. Tables are created on first start, and while the database has no content the menus use the made-up example_content.py. Add codes and parts from Admin Panel → Add Code / Add Part. Stop with Ctrl+C.

Development

pip install -e ".[dev]"
pre-commit run --all-files
pytest

CI fails if any document, image or spreadsheet file is committed, or if the package imports anything from a host application. See CONTRIBUTING.md for how to make a change.

Licence

MIT. The licence covers the code only; site content supplied by a host is not part of this repository.

Metadata

Release files for turbine-troubleshooter-bot 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for turbine-troubleshooter-bot 1.1.0
File Size Uploaded Provenance Actions
turbine_troubleshooter_bot-1.1.0.tar.gz 65.3 kB With provenance Details for turbine_troubleshooter_bot-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for turbine-troubleshooter-bot 1.1.0
File Interpreter ABI Platform Actions
turbine_troubleshooter_bot-1.1.0-py3-none-any.whl Python 3 none any Details for turbine_troubleshooter_bot-1.1.0-py3-none-any.whl

Total release size: 122.2 kB

Release files / turbine_troubleshooter_bot-1.1.0.tar.gz

Download URL turbine_troubleshooter_bot-1.1.0.tar.gz
Size 65.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6433c87db9c5d3e3a4b253c233e51133633f84a022665d5e0c6ac77b807f21d6
BLAKE2b-256 checksum
How to use checksums
6b4ba5eefbcda16e970f60654a085ed70ffa1de80bf17258495ac55263f6db87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / turbine_troubleshooter_bot-1.1.0-py3-none-any.whl

Download URL turbine_troubleshooter_bot-1.1.0-py3-none-any.whl
Size 56.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
178a2886d2e3e7e9e8e79fd3832e8ecc305ecd76d1501103f9f99975b14339d1
BLAKE2b-256 checksum
How to use checksums
9e04cdaad20616f2855e3a0094593b768f8e92234de0b938fc920a94c326677f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for turbine-troubleshooter-bot 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for turbine_troubleshooter_bot-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page