telegram.InputFile

class telegram.InputFile(obj, filename=None, attach=None)

Bases: object

This object represents a Telegram InputFile.

input_file_content

The binaray content of the file to send.

Type:bytes
filename

Optional, Filename for the file to be sent.

Type:str
attach

Optional, attach id for sending multiple files.

Type:str
Parameters:
  • obj (File handler) – An open file descriptor.
  • filename (str, optional) – Filename for this InputFile.
  • attach (bool, optional) – Whether this should be send as one file or is part of a collection of files.
Raises:

TelegramError

static is_image(stream)

Check if the content file is an image by analyzing its headers.

Parameters:stream (str) – A str representing the content of a file.
Returns:The str mime-type of an image.
Return type:str