mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #284 from Kuznitsin/master
Non-ASCII chars for filename.
This commit is contained in:
commit
4c4e8deaee
@ -1,6 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
try:
|
||||||
|
from requests.packages.urllib3 import fields
|
||||||
|
except ImportError:
|
||||||
|
fields = None
|
||||||
import telebot
|
import telebot
|
||||||
from telebot import types
|
from telebot import types
|
||||||
from telebot import util
|
from telebot import util
|
||||||
@ -29,6 +33,8 @@ def _make_request(token, method_name, method='get', params=None, files=None, bas
|
|||||||
logger.debug("Request: method={0} url={1} params={2} files={3}".format(method, request_url, params, files))
|
logger.debug("Request: method={0} url={1} params={2} files={3}".format(method, request_url, params, files))
|
||||||
read_timeout = READ_TIMEOUT
|
read_timeout = READ_TIMEOUT
|
||||||
connect_timeout = CONNECT_TIMEOUT
|
connect_timeout = CONNECT_TIMEOUT
|
||||||
|
if files and fields:
|
||||||
|
fields.format_header_param = _no_encode(fields.format_header_param)
|
||||||
if params:
|
if params:
|
||||||
if 'timeout' in params: read_timeout = params['timeout'] + 10
|
if 'timeout' in params: read_timeout = params['timeout'] + 10
|
||||||
if 'connect-timeout' in params: connect_timeout = params['connect-timeout'] + 10
|
if 'connect-timeout' in params: connect_timeout = params['connect-timeout'] + 10
|
||||||
@ -568,6 +574,15 @@ def _convert_markup(markup):
|
|||||||
return markup
|
return markup
|
||||||
|
|
||||||
|
|
||||||
|
def _no_encode(func):
|
||||||
|
def wrapper(key, val):
|
||||||
|
if key == 'filename':
|
||||||
|
return '{0}={1}'.format(key, val)
|
||||||
|
else:
|
||||||
|
return func(key, val)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class ApiException(Exception):
|
class ApiException(Exception):
|
||||||
"""
|
"""
|
||||||
This class represents an Exception thrown when a call to the Telegram API fails.
|
This class represents an Exception thrown when a call to the Telegram API fails.
|
||||||
|
Loading…
Reference in New Issue
Block a user