telegraph.py 858 B

1234567891011121314151617181920212223242526272829
  1. from pyrogram import filters
  2. from pyrogram.types import Message
  3. from wbb import app, telegraph
  4. from wbb.core.decorators.errors import capture_err
  5. __MODULE__ = "Telegraph"
  6. __HELP__ = "/telegraph [Page name]: Paste styled text on telegraph."
  7. @app.on_message(filters.command("telegraph"))
  8. @capture_err
  9. async def paste(_, message: Message):
  10. reply = message.reply_to_message
  11. if not reply or not reply.text:
  12. return await message.reply("Reply to a text message")
  13. if len(message.command) < 2:
  14. return await message.reply("**Usage:**\n /telegraph [Page name]")
  15. page_name = message.text.split(None, 1)[1]
  16. page = telegraph.create_page(
  17. page_name, html_content=reply.text.html.replace("\n", "<br>")
  18. )
  19. return await message.reply(
  20. f"**Posted:** {page['url']}",
  21. disable_web_page_preview=True,
  22. )