D
Try direct modification of the library for API telegram.If you installed the library directly into the python, it's in the next director:Python{версия}/Lib/site-packages/{имя_библиотеки}
If you work in a virtual environment, it's in:{имя_виртуального_окружения}/Lib/site-packages/{имя_библиотеки}
Find the module responsible for requests, in most of the libraries for interaction with API, it is designed so that requests are carried out in one function, it needs to be modified. By example, I'm showing pyTelegramBotAPI, function. _make_request I'm lying. ♪ ♪ /Lib/site-packages/telebot/apihelperpy. and looks like (a code partially cut to distinguish the main parts):def _make_request(token, method_name, method='get', params=None, files=None):
if API_URL:
request_url = API_URL.format(token, method_name)
else:
request_url = "https://api.telegram.org/bot{0}/{1}".format(token, method_name)
read_timeout = READ_TIMEOUT
connect_timeout = CONNECT_TIMEOUT
#...
if RETRY_ON_ERROR:
got_result = False
current_try = 0
while not got_result and current_try<MAX_RETRIES-1:
current_try+=1
try:
result = _get_req_session().request(
method, request_url, params=params, files=files,
timeout=(connect_timeout, read_timeout), proxies=proxy)
got_result = True
except HTTPError:
#...
if not got_result:
result = _get_req_session().request(
method, request_url, params=params, files=files,
timeout=(connect_timeout, read_timeout), proxies=proxy)
else:
result = _get_req_session().request(
method, request_url, params=params, files=files,
timeout=(connect_timeout, read_timeout), proxies=proxy)
#...
json_result = _check_result(method_name, result)
if json_result:
return json_result['result']
In the pyTelegramBotAPI_get_req_session() returns the object requests.Session(), which means that it is sufficient to modify the lines of the request (in the example of the code the certificate checks are off):result = _get_req_session().request(
method, request_url, params=params, files=files,
timeout=(connect_timeout, read_timeout), proxies=proxy, verify=False)
If the library is asynchronous, it uses aiohttps how it works with certificates as described in https://docs.aiohttp.org/en/stable/client_advanced.html#ssl-control-for-tcp-sockets ♪ I set an example with only one synchronized library, but in all +- the same way.