ehForwarderBot / efb-telegram-master

EFB Telegram Master Channel, a channel for EH Forwarder Bot.
GNU Affero General Public License v3.0
223 stars 79 forks source link

File transfer failed when file name contains non-ASCII characters. #54

Closed blueset closed 5 years ago

blueset commented 5 years ago

Issue that exists in upstream library python-telegram-bot since 11.0.

The issue is now fixed in 12.0 beta, along with multiple compatibility changes.

Timeline

Relevant traceback

2019-04-20 04:05:04,518 [ERROR]: efb_telegram_master.slave_message (slave_message.send_message; slave_message.py:214)
    [3454101684214458072] Error occurred while processing message from slave channel.
Message: [Redacted]
BadRequest()
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 149, in send_message
    tg_msg = self.slave_message_file(msg, tg_dest, msg_template, old_msg_id, target_msg_id, reply_markup)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/slave_message.py", line 418, in slave_message_file
    reply_markup=reply_markup)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 230, in caption_affix
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/efb_telegram_master/bot_manager.py", line 342, in send_document
    return self.updater.bot.send_document(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 65, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/bot.py", line 90, in decorator
    result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 305, in post
    result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs)
  File "/usr/local/lib/python3.6/site-packages/telegram/utils/request.py", line 223, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Wrong url host
coffeecaty commented 5 years ago

thank you for your cooperation

coffeecaty commented 5 years ago

excuse me, before we can fixed the bug,can you make a update to raise a message like "you have a file,please check it on your phone" on the telegram bot when the bug happened? now i even have no idea whether there are files or not

blueset commented 5 years ago

I'll try to include a workaround notification when I have time. Thanks for the suggestion.

blueset commented 5 years ago

Since python-telegram-bot won't seem to be releasing the next update anytime soon, I have implemented a monkey patch on ETM side to suppress the "RFC2231 form field name" issue.

blueset commented 5 years ago

Monkey patch released.

blueset commented 5 years ago

PTB released first stable v12. ETM will follow up later to merge in the ptb12 branch and release a new beta to PyPI.

blueset commented 5 years ago

New version with ptb12 is merged and released.