Advertisement
disk6969

Untitled

Sep 8th, 2024 (edited)
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. from telethon import types
  2. from telethon.extensions import markdown
  3.  
  4. class CustomMarkdown:
  5.     @staticmethod
  6.     def parse(text):
  7.         text, entities = markdown.parse(text)
  8.         for i, e in enumerate(entities):
  9.             if isinstance(e, types.MessageEntityTextUrl):
  10.                 if e.url.startswith('quote'):
  11.                     collapse = e.url.endswith('collapse')
  12.                     entities[i] = types.MessageEntityBlockquote(e.offset, e.length, collapsed=collapse)
  13.         return text, entities
  14.  
  15.     @staticmethod
  16.     def unparse(text, entities):
  17.         return markdown.unparse(text, entities)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement