Talk to bot father, https://telegram.me/BotFather, and send message /newbot
to create a new bot, follow the instruction, once done, you will get a token
pip install telegram-send
to install the required moduletelegram-send --configure
to link to your created bot
Then insert the token that you got from bot father, press enter, obtain the passcode from the terminal and send it via the created bot in Telegram chat
Send multiple text messages separately, an item in a list represents a message.
telegram_send.send(messages=["Message 1", "Message 2"])
The image will be imported from local machine, open it as a binary format.
with open("./files/image.jpg", "rb") as image:
telegram_send.send(images=[image])
You may combine few things with different formats into a single message, such as text, file, image with caption, sticker and so on.
with open("./files/image.jpg", "rb") as image:
telegram_send.send(messages=["Hey!\nThis is a new message!"], files=[image], captions=["This is a image!"])
To send text and file in a single message, you may use "caption" to send the description that attached with the file.
with open("./files/simon_github.txt") as text_file:
telegram_send.send(files=[text_file], captions=["This is a text file!"])