summaryrefslogtreecommitdiffstats
path: root/telepot/hack.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-07-19 10:42:15 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-07-19 10:42:15 +0300
commit5a636abf7e98a5687811167917d0e07103599bc8 (patch)
tree682f8d70d194c6bf02b750780f05689fcb83ba5a /telepot/hack.py
parente1ae18d1bc9e26f8ab817ca1c1e4e271badf02ad (diff)
Vendor the unmaintained telepot dependency
Diffstat (limited to 'telepot/hack.py')
-rw-r--r--telepot/hack.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/telepot/hack.py b/telepot/hack.py
new file mode 100644
index 0000000..029bd19
--- /dev/null
+++ b/telepot/hack.py
@@ -0,0 +1,16 @@
+try:
+ import urllib3.fields
+
+ # Do not encode unicode filename, so Telegram servers understand it.
+ def _noencode_filename(fn):
+ def w(name, value):
+ if name == 'filename':
+ return '%s="%s"' % (name, value)
+ else:
+ return fn(name, value)
+ return w
+
+ urllib3.fields.format_header_param = _noencode_filename(urllib3.fields.format_header_param)
+
+except (ImportError, AttributeError):
+ pass