MCPcopy Create free account
hub / github.com/eternnoir/pyTelegramBotAPI / polling

Method polling

telebot/__init__.py:1152–1228  ·  view source on GitHub ↗

This function creates a new Thread that calls an internal __retrieve_updates function. This allows the bot to retrieve Updates automatically and notify listeners and message handlers accordingly. Warning: Do not call this function more than once! Always gets update

(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=False, interval: Optional[int]=0,
                timeout: Optional[int]=20, long_polling_timeout: Optional[int]=20,
                logger_level: Optional[int]=logging.ERROR, allowed_updates: Optional[List[str]]=None,
                none_stop: Optional[bool]=None, restart_on_change: Optional[bool]=False, path_to_watch: Optional[str]=None)

Source from the content-addressed store, hash-verified

1150
1151
1152 def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=False, interval: Optional[int]=0,
1153 timeout: Optional[int]=20, long_polling_timeout: Optional[int]=20,
1154 logger_level: Optional[int]=logging.ERROR, allowed_updates: Optional[List[str]]=None,
1155 none_stop: Optional[bool]=None, restart_on_change: Optional[bool]=False, path_to_watch: Optional[str]=None):
1156 """
1157 This function creates a new Thread that calls an internal __retrieve_updates function.
1158 This allows the bot to retrieve Updates automatically and notify listeners and message handlers accordingly.
1159
1160 Warning: Do not call this function more than once!
1161
1162 Always gets updates.
1163
1164 .. deprecated:: 4.1.1
1165 Use :meth:`infinity_polling` instead.
1166
1167 .. note::
1168
1169 Install watchdog and psutil before using restart_on_change option.
1170
1171 :param interval: Delay between two update retrivals
1172 :type interval: :obj:`int`
1173
1174 :param non_stop: Do not stop polling when an ApiException occurs.
1175 :type non_stop: :obj:`bool`
1176
1177 :param timeout: Request connection timeout
1178 :type timeout: :obj:`int`
1179
1180 :param skip_pending: skip old updates
1181 :type skip_pending: :obj:`bool`
1182
1183 :param long_polling_timeout: Timeout in seconds for long polling (see API docs)
1184 :type long_polling_timeout: :obj:`int`
1185
1186 :param logger_level: Custom (different from logger itself) logging level for infinity_polling logging.
1187 Use logger levels from logging as a value. None/NOTSET = no error logging
1188 :type logger_level: :obj:`int`
1189
1190 :param allowed_updates: A list of the update types you want your bot to receive.
1191 For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types.
1192 See util.update_types for a complete list of available update types.
1193 Specify an empty list to receive all update types except chat_member (default).
1194 If not specified, the previous setting will be used.
1195
1196 Please note that this parameter doesn't affect updates created before the call to the get_updates,
1197 so unwanted updates may be received for a short period of time.
1198 :type allowed_updates: :obj:`list` of :obj:`str`
1199
1200 :param none_stop: deprecated.
1201 :type none_stop: :obj:`bool`
1202
1203 :param restart_on_change: Restart a file on file(s) change. Defaults to False
1204 :type restart_on_change: :obj:`bool`
1205
1206 :param path_to_watch: Path to watch for changes. Defaults to None
1207 :type path_to_watch: :obj:`str`
1208
1209 :return:

Calls 4

__skip_updatesMethod · 0.95
__threaded_pollingMethod · 0.95

Tested by

no test coverage detected