Skip to content

Instantly share code, notes, and snippets.

@hugmouse
Created June 11, 2022 17:10
Show Gist options
  • Save hugmouse/374dfea8cc4a46de18bae9cc3f373b81 to your computer and use it in GitHub Desktop.
Save hugmouse/374dfea8cc4a46de18bae9cc3f373b81 to your computer and use it in GitHub Desktop.
Re-send last photo to the user/bot
import asyncio
import pyrogram.types
from pyrogram import Client
from pyrogram.filters import photo
api_id = 123
api_hash = "hash"
app = Client("my_account", api_id=api_id, api_hash=api_hash)
chat_id = 123 # bot id
with app:
me = app.get_me()
@app.on_message(filters=[photo], group=chat_id)
async def msg_handler(client: Client, msg: pyrogram.types.Message):
if msg.chat.id != chat_id:
return
if me.id == msg.from_user.id:
return
await asyncio.sleep(5)
await client.send_photo(msg.chat.id, msg.photo.file_id)
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment