mirror of
https://github.com/SrIzan10/starters.git
synced 2026-05-01 11:05:16 +00:00
Add python-telegram-bot (#226)
* Add python-telegram-bot Update Update bot.py * Update bot.py * Update requirements.txt
This commit is contained in:
1
examples/python-telegram-bot/Procfile
Normal file
1
examples/python-telegram-bot/Procfile
Normal file
@@ -0,0 +1 @@
|
||||
web: python bot.py
|
||||
28
examples/python-telegram-bot/README.md
Normal file
28
examples/python-telegram-bot/README.md
Normal file
@@ -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.
|
||||
|
||||
[](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/).
|
||||
15
examples/python-telegram-bot/bot.py
Normal file
15
examples/python-telegram-bot/bot.py
Normal file
@@ -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()
|
||||
1
examples/python-telegram-bot/requirements.txt
Normal file
1
examples/python-telegram-bot/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
python-telegram-bot
|
||||
Reference in New Issue
Block a user