{"id":13800969,"url":"https://github.com/jordiprats/micropython-utelegram","last_synced_at":"2026-02-09T07:41:24.645Z","repository":{"id":41998501,"uuid":"293490239","full_name":"jordiprats/micropython-utelegram","owner":"jordiprats","description":"Telegram API wrapper for microPython","archived":false,"fork":false,"pushed_at":"2023-10-06T16:48:04.000Z","size":30,"stargazers_count":88,"open_issues_count":8,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-13T10:43:05.327Z","etag":null,"topics":["esp32","micropython","telegram-bot-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jordiprats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-07T10:01:59.000Z","updated_at":"2025-02-28T15:27:25.000Z","dependencies_parsed_at":"2024-08-04T00:16:15.321Z","dependency_job_id":null,"html_url":"https://github.com/jordiprats/micropython-utelegram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jordiprats/micropython-utelegram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordiprats%2Fmicropython-utelegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordiprats%2Fmicropython-utelegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordiprats%2Fmicropython-utelegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordiprats%2Fmicropython-utelegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jordiprats","download_url":"https://codeload.github.com/jordiprats/micropython-utelegram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jordiprats%2Fmicropython-utelegram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29258791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T04:11:57.159Z","status":"ssl_error","status_checked_at":"2026-02-09T04:11:56.117Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["esp32","micropython","telegram-bot-api"],"created_at":"2024-08-04T00:01:18.140Z","updated_at":"2026-02-09T07:41:24.629Z","avatar_url":"https://github.com/jordiprats.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# micropython-utelegram\n\nThis library provides a **microPython** interface for for a subset of the **Telegram Bot API**. Have been tested on an **ESP32** but should work just fine on an **ESP8266**. Further tests have been done on **RP2040** with successful results.\n\n## Your first bot\n\nOn the demo folder you will find an example bot. \n\nFirst you'll need to create a new bot using the **BotFather** to get a token for your bot. Once you have it rename the **config.py-demo** and set the variables (WiFI SID/password and your bot token):\n\n```python\nwifi_config = {\n    'ssid':'DEMO',\n    'password':'PASSW0RD'\n}\n\nutelegram_config = {\n    'token': 'TOKEN'\n}\n```\n\nIf you have your **ESP32** connected as **/dev/ttyUSB0** you can use the upload.sh script to upload the bot code to your **micropython enabled ESP32**:\n\n```bash\n./upload.sh\n```\n\n### Example bot code\n\n#### Initialize bot\n\nTo create a new bot you just need to create a ubot object passing the token the **BotFather** have provided:\n\n```python\nbot = utelegram.ubot(utelegram_config['token'])\n```\n\n#### Register handlers\n\nHandlers will receive the raw message as a parameter:\n\n```python\ndef reply_ping(message):\n    bot.send(message['message']['chat']['id'], 'pong')\n```\n\nMessages will be in the following format:\n\n```python\n{\n   \"update_id\":302445393,\n   \"message\":{\n      \"message_id\":1492,\n      \"from\":{\n         \"id\":123456789,\n         \"is_bot\":False,\n         \"language_code\":\"en\",\n         \"first_name\":\"Jordi\"\n      },\n      \"text\":\"/ping\",\n      \"date\":1599563930,\n      \"entities\":[\n         {\n            \"offset\":0,\n            \"length\":5,\n            \"type\":\"bot_command\"\n         }\n      ],\n      \"chat\":{\n         \"id\":123456789,\n         \"type\":\"private\",\n         \"first_name\":\"Jordi\"\n      }\n   }\n}\n```\n\nYou can register handlers using the **register** method:\n\n```python\nbot.register('/ping', reply_ping)\n```\n\nAnd optionally set a **default handler** for any other message:\n\n```python\nbot.set_default_handler(get_message)\n```\n\n### Reply to messages\n\nUsing the send function we can reply to messages, the parameters are:\n\n* **chat ID**: chat ID is the same as the user ID except for group chats\n* **message**: text to send\n\nFor example, we can use the incoming message to get the **chat_id** to reply to:\n\n```python\nbot.send(message['message']['chat']['id'], 'pong')\n```\n\n### Bot loop\n\nWe can either let the bot loop but itself to reply to messages:\n\n```python\nbot.listen()\n```\n\nOr we can loop manually using the **read_once()** function:\n\n```python\nbot.read_once()\n```\n\nUsing this method you should add a sleep between each time we poll the Telegram API\n\n## Other examples\n\n* [Telegram integrated countdown timer](https://github.com/jordiprats/micropython-remainigdays)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordiprats%2Fmicropython-utelegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordiprats%2Fmicropython-utelegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordiprats%2Fmicropython-utelegram/lists"}