alexander-akhmetov / python-telegram

Python client for the Telegram's tdlib
MIT License
610 stars 122 forks source link

Send message as HTML or Markdown #296

Closed aldev12 closed 1 year ago

aldev12 commented 2 years ago

How i can send message, which will be processing as HTML or Markdown?

I found it https://python-telegram.readthedocs.io/en/0.14.0/tdlib.html but that doesn't explain anything. Is it possible to add an example to send a message like HTML?

alexander-akhmetov commented 2 years ago

Hi! Sorry, there is no example, unfortunately. You can check out how send_message works and then you'll need to figure out how to call tdlib with the proper parameters. I think you have to pass a list of entities (documentation) along with the text, but I haven't tested this:

result = tg.call_method(
    'sendMessage',
    params={
        'chat_id': args.chat_id,
        'input_message_content': {
            '@type': 'inputMessageText',
            'text': {'@type': 'formattedText', 'text': 'some message', 'entities': [...]},
        },                                                                                 
    },                                                                                     
)
alexander-akhmetov commented 1 year ago

346 Adds markup support (the change is released in version 0.17.0). See the README.md and the text module for more information.