'How to send documents like html in telebot python or with api

import requests

files = {
    'chat_id': (None, '1937802988'),
    'document': ('answer.html', open('answer.html', 'rb')),
}

response = requests.post('https://api.telegram.org/<token>/sendDocument', files=files)


Solution 1:[1]

To send documents via telebot use send_document. This example sends HTML and PDF files.

import telebot
from telebot import types

bot = telebot.TeleBot('<TOKEN>')

@bot.message_handler(content_types=['text'])
def start(message):

    html_doc = open('answer.html', 'rb')
    bot.send_document(message.from_user.id, html_doc);

    pdf_doc = open('file.pdf', 'rb')
    bot.send_document(message.from_user.id, pdf_doc);

bot.polling(none_stop = True, interval=0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paton