diff --git a/examples/python-telegram-bot/Procfile b/examples/python-telegram-bot/Procfile new file mode 100644 index 0000000..9b89691 --- /dev/null +++ b/examples/python-telegram-bot/Procfile @@ -0,0 +1 @@ +web: python bot.py \ No newline at end of file diff --git a/examples/python-telegram-bot/README.md b/examples/python-telegram-bot/README.md new file mode 100644 index 0000000..ea45f84 --- /dev/null +++ b/examples/python-telegram-bot/README.md @@ -0,0 +1,28 @@ +--- +title: Python Telegram Bot +description: A Telegram Bot Written in Python +tags: + - python + - python-discord-bot + - telegram +--- + +# Python-Telegram-Bot + +This example starts a Telegram bot using [python-telegram-bot](https://www.python-telegram-bot.org/) library. + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2Frailwayapp%2Fexamples%2Ftree%2Fmaster%2Fexamples%2Fpython-telegram-bot&envs=TOKEN&TOKENDesc=The+Telegram+Bot%27s+Token+%28Generate+a+token+from+%40BotFather+if+you+don%27t+have+one%21%29) + +## ✨ Features + +- Python +- Python Telegram Bot + +## 💁‍♀️ How to use + +- Install packages using `pip install -r requirements.txt` +- Start the bot using `python bot.py` + +## 📝 Notes + +This is a basic bot with the command `/start`, more information can be founded at the [offical documentation](https://python-telegram-bot.readthedocs.io/en/stable/). \ No newline at end of file diff --git a/examples/python-telegram-bot/bot.py b/examples/python-telegram-bot/bot.py new file mode 100644 index 0000000..0a6f972 --- /dev/null +++ b/examples/python-telegram-bot/bot.py @@ -0,0 +1,15 @@ +from telegram import Update +from telegram.ext import Updater, CommandHandler, CallbackContext +import os + +def start(update: Update, context: CallbackContext) -> None: + update.message.reply_text(f'Hello {update.effective_user.first_name}\nI am a sample Telegram bot made with python-telegram-bot!') + +updater = Updater(os.environ.get("TOKEN"), use_context=True) + +updater.dispatcher.add_handler(CommandHandler('start', start)) + +print("Bot started successfully") + +updater.start_polling() +updater.idle() diff --git a/examples/python-telegram-bot/requirements.txt b/examples/python-telegram-bot/requirements.txt new file mode 100644 index 0000000..850869a --- /dev/null +++ b/examples/python-telegram-bot/requirements.txt @@ -0,0 +1 @@ +python-telegram-bot