
Telegram MTProto API Framework for Python
Homepage
•
Documentation
•
Releases
•
News
Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
pip3 install -U pyrogram tgcrypto- Python And Pip Installed
- VS Code (IDE)
- Basic Knowledge About Python Programming (For Advanced Users)
- Secondary Telegram Account
- Telegram Bot
- Set Your Api Id And Api Hash Bot Token And Authenticate Them:
from pyrogram import Client, filters
bot = Client(
"my_bot",
api_id = put_your_id,
api_hash = "put_your_creditnal",
bot_token = "put_bot_token"
)
print("i am runnig")
bot.run()@bot.on_message(filters.command("start"))
def start_command(client, message):
bot.send_message(message.chat.id,"**hi buddy i am running**")- you can set help command with same steps just replace start with help:
@bot.on_message(filters.command("help"))@bot.on_message(filters.command("image"))
def send_image (bot, message):
bot.send_photo (message.chat.id,"https://imgur.com/gallery/wYTCtRu")@bot.on_message(filters.document & filters.private)
def get_document(bot, message):
message.reply(message.document.file_id) #get document id
#send document
@bot.on_message(filters.command("doc"))
def send_document(bot, message):
bot.send_document(message.chat.id,"BQACAgUAAxkBAANUYrwlqbV0jIJnR8OwuVTCbYHS_7MAAtYFAALMlNlVyGtBqixT5f4eBA")- You Can Send Video, Audio, Voice, Animation (Gif), Stickers With Given Document Command
- Just Replace
Filters.DocumentWithFilters.Animation - Example:
@bot.on_message(filters.animation & filters.private)
def get_gif(bot, message):
message.reply(message.animation.file_id)
@bot.on_message(filters.command("gif"))
def send_gif(bot, message):
bot.send_animation(message.chat.id,"CgACAgQAAxkBAAOiYsfXIDhsfQOGMPnM8TYdqwHbOZQAAiIDAAKhZQRT0peUDq_1IFseBA")- This simple echo bot replies to every private text same as user message:
@bot.on_message (filters.text & filters.private)
def echobot (client, message):
message.reply_text(message.text)- For More Commands And More Info, Pls View Examples.Py
- Examples.Py Includes Ban, Unban, Mute, Buttons, Id And Leave
- For more info,Check Pyrogram Documentation