{"id":24017575,"url":"https://github.com/piraces/python-telegram-bot","last_synced_at":"2025-05-07T03:03:32.533Z","repository":{"id":93937723,"uuid":"377217353","full_name":"piraces/python-telegram-bot","owner":"piraces","description":"A simple, minimal Telegram bot template made in Python.","archived":false,"fork":false,"pushed_at":"2021-06-16T07:25:34.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T05:33:35.361Z","etag":null,"topics":["dockerfile","python","telegram","telegram-bot","telegram-bot-example","template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piraces.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":"2021-06-15T15:51:52.000Z","updated_at":"2024-06-30T07:52:06.000Z","dependencies_parsed_at":"2023-04-01T13:48:12.985Z","dependency_job_id":null,"html_url":"https://github.com/piraces/python-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piraces%2Fpython-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piraces%2Fpython-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piraces%2Fpython-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piraces%2Fpython-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piraces","download_url":"https://codeload.github.com/piraces/python-telegram-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804208,"owners_count":21806769,"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":["dockerfile","python","telegram","telegram-bot","telegram-bot-example","template"],"created_at":"2025-01-08T09:41:35.892Z","updated_at":"2025-05-07T03:03:32.413Z","avatar_url":"https://github.com/piraces.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Python Telegram bot template\n\nThis repository contains all you may need to bootstrap your new Telegram bot in Python.\nIt makes use of the awesome [`python-telegram-bot`](https://github.com/python-telegram-bot/python-telegram-bot) library, \nand a [basic example](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/echobot.py) \nfrom the official repository.\n\n# Getting started\n\nJust tap on the **\"Use this template\"** button in the top toolbar of the repository and introduce the details of the project\nyou want to create.\n\nAfter that, you only need to clone your own repository and make all the modifications you need.\n\n# What is included?\n\nJust the essentials.\n\n## A fully functional example bot\n\nThis template includes an example in the directory `/src` containing the [`echobot.py` example from the official \nrepository](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/example).\nThis bot will simply reply to each text message with a message that contains the same text.\n\n## A Dockerfile\n\nA simple `Dockerfile` is provided for creating a container for the bot.\nThis `Dockerfile` only builds a simple container using the \n[official `python` base image](https://hub.docker.com/_/python) and a few commands to install the requirements for the \nbot project, copy the source files and establish the bot token as an \n[environment variable](https://en.wikipedia.org/wiki/Environment_variable).\n\n🛑 **Note**: this `Dockerfile` uses as base the **latest** version of the Python docker image, which will change \nin the future. In order to make your container more stable, change the tag to a specific version, which will ensure no \npossible breaking changes.\nFor example, if you want to stick with `Python 3.9`:\n```dockerfile\n# set base image (host OS)\nFROM python:3.9\n\n# Rest of the file...\n```\n\n## A `requirements.txt` file\n\nThis file contains all dependencies for the bot project.\nFor the template and the basic behaviour of the bot, only the package `python-telegram-bot` is needed.\n\nYou can just run this command in order to get dependencies installed:\n```shell\npip install -r requirements.txt\n```\n\n🛑 **Note**: the version number for the package **is not being set**. This will cause downloading always the latest version \nof the package. If you don't want this behaviour, please modify the `requirements.txt` file to set it.\nFor example:\n```text\npython-telegram-bot==13.6\n```\n\n# Configuring your new bot\n\nThe only thing you need to get started with bots in Telegram is an account and to talk to \n[BotFather](https://t.me/BotFather). This bot will provide you instructions to create a new bot, and at the end will\nprovide you **a token**.\n\nYou will need this token and keep it secret (**don't ever commit it to GitHub or make it public in any way**).\nOnce you have this token, you can set it to the bot via an \n[environment variable](https://en.wikipedia.org/wiki/Environment_variable) or directly in code.\n\n## Setting the token as an environment variable\n\nIf using the `Dockerfile` substitute the line `ENV TOKEN=\"\"` with your token inside the double quotes.\nFor example:\n```dockerfile\n# ... previous file content\n\n# set the token for the telegram bot\nENV TOKEN=\"mysupersecrettoken\"\n\n# Rest of the file...\n```\n\nIf running your code directly from the terminal, declare the environment variable `TOKEN` with your token as its \nvalue.\nFor example, in Linux or macOS:\n```shell\nexport TOKEN=\"mysupersecrettoken\"\n```\n\nOr in Windows (Powershell):\n```powershell\n$env:Token = 'mysupersecrettoken'\n```\n\n## Setting the token inside the code\n\nSearch in the `main.py` file for the `PUT_YOUR_TOKEN_HERE` word (it is in the `main` method).\nAs you can see, the program will attempt to load the token from an environment variable named `TOKEN`.\nNevertheless, if this environment variable does not exist, the second parameter will be used by default.\n\nIf you change that second parameter, the bot will get the correct token directly from the code \n(just ensure the is no environment variable named `TOKEN` created).\n\n🛑 **Note**: if using the provided `Dockerfile`, comment out the line starting with `ENV` since it will set the \nenvironment variable to an empty string, which will cause your bot to fail starting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiraces%2Fpython-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiraces%2Fpython-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiraces%2Fpython-telegram-bot/lists"}