Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telethon import types
- from telethon.extensions import markdown
- class CustomMarkdown:
- @staticmethod
- def parse(text):
- text, entities = markdown.parse(text)
- for i, e in enumerate(entities):
- if isinstance(e, types.MessageEntityTextUrl):
- if e.url.startswith('quote'):
- collapse = e.url.endswith('collapse')
- entities[i] = types.MessageEntityBlockquote(e.offset, e.length, collapsed=collapse)
- return text, entities
- @staticmethod
- def unparse(text, entities):
- return markdown.unparse(text, entities)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement