Skip to content

NEWBIENOOB-0/pyrogram-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Learn Pyrogram

Pyrogram
Telegram MTProto API Framework for Python
Homepage Documentation Releases News

Pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots

Installing

pip3 install -U pyrogram tgcrypto

Requirements

  • Python And Pip Installed
  • VS Code (IDE)
  • Basic Knowledge About Python Programming (For Advanced Users)
  • Secondary Telegram Account
  • Telegram Bot

Let's get started

Setting up enviroments

  • 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()

Set Your First Command

@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"))

Send Image

@bot.on_message(filters.command("image"))
def send_image (bot, message):
    bot.send_photo (message.chat.id,"https://imgur.com/gallery/wYTCtRu")

Send Documnet

@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.Document With Filters.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")

Echobot

  • 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

About

Learn Pyrogram With Examples Super Easy

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages