Telegram provides API for sending messages to users as bot. You may send messages via HTTP POST method using any programming language. I use Python and Requests library.
URL address for sending message:
https://api.telegram.org/bot<token_from_botfather>/sendMessage
Body of message:
{
"chat_id": chat_id,
"text": "Hello World!"
}
If you want to markup your message with Markdown - add "parse_mode" parameter in body of JSON:
{
"chat_id": chat_id,
"text": "Hello World!",
"parse_mode": "Markdown"
}
Here steps needed for successfully complete the task:
- Find
Now we are trying to send the document:
CODEimport requests
def send_document(TOKEN, chat_id, file):
url = 'https://api.telegram.org/bot{}/sendDocument'.format(TOKEN)
data = {'chat_id': chat_id}
document = open(file, 'rb')
files = {'document': document}
response = requests.post(url, data=data, files=files)
return response
send_document('token_from_botfather', recipient_id, '/path/to/any/document.file')
Result:
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.

SOCIAL SHARE CARD GENERATOR