Skip to content

Utils

Package containing the Telegram utils functions and classes.

TelegramTqdm

This class allows to send through a Telegram Bot a progress bar.

__call__(self, iterable=None, show_last_update=False, desc=None, total=None, leave=True, ncols=None, mininterval=1.0, maxinterval=10.0, miniters=None, ascii=False, disable=False, unit='it', unit_scale=False, dynamic_ncols=False, smoothing=0.3, bar_format=None, initial=0, position=None, postfix=None, unit_divisor=1000, gui=False, **kwargs) special

Progress bar getting function. It uses the same interface of the tqdm library.

Returns:

Type Description

tqdm object

Source code in bob_telegram_tools\utils.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __call__(self, iterable=None, show_last_update=False,
             desc=None, total=None, leave=True, ncols=None, mininterval=1.0, maxinterval=10.0,
             miniters=None, ascii=False, disable=False, unit='it',
             unit_scale=False, dynamic_ncols=False, smoothing=0.3,
             bar_format=None, initial=0, position=None, postfix=None,
             unit_divisor=1000, gui=False, **kwargs):
    """
    Progress bar getting function. It uses the same interface of the [tqdm](https://tqdm.github.io)  library.

    Returns:
        tqdm object

    """
    params = {
        'desc': desc,
        'total': total,
        'leave': leave,
        'file': self.tg_io,
        'ncols': ncols,
        'mininterval': mininterval,
        'maxinterval': maxinterval,
        'miniters': miniters,
        'ascii': ascii,
        'disable': disable,
        'unit': unit,
        'unit_scale': unit_scale,
        'dynamic_ncols': dynamic_ncols,
        'smoothing': smoothing,
        'bar_format': bar_format,
        'initial': initial,
        'position': position,
        'postfix': postfix,
        'unit_divisor': unit_divisor,
        'gui': gui
    }

    params.update(kwargs)

    if iterable is not None:
        params['iterable'] = iterable

    return tqdm(**params)

__init__(self, bot, show_last_update=False) special

Constructor

Parameters:

Name Type Description Default
bot TelegramBot

TelegramBot object

required
show_last_update bool

True to receive the time of the last update

False
Source code in bob_telegram_tools\utils.py
34
35
36
37
38
39
40
41
42
43
44
def __init__(self, bot: TelegramBot, show_last_update: bool = False):
    """
    Constructor

    Arguments:
        bot: TelegramBot object

        show_last_update: True to receive the time of the last update
    """
    self.bot = bot
    self.tg_io = _TelegramIO(self.bot, show_last_update)