Nanoseb / ncTelegram

A ncurse Telegram client developed in Python
GNU General Public License v3.0
312 stars 26 forks source link

nctelegram crashing with TypeError... #12

Open ninjaaron opened 8 years ago

ninjaaron commented 8 years ago

There's a certain buffer that, whenever I try to open it, it crashes out with this error message:

Traceback (most recent call last):
  File "/usr/bin/nctelegram", line 79, in <module>
    ncTelegram.Telegram_ui(config_full)
  File "/usr/lib/python3.5/site-packages/ncTelegram/__init__.py", line 87, in __init__
    self.main_loop.run()
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
    self._run()
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run
    self._loop()
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop
    self._watch_files[fd]()
  File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 503, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3.5/site-packages/ncTelegram/ui_chanwidget.py", line 194, in keypress
    key = super(ChanWidget, self).keypress(size, key)
  File "/usr/lib/python3.5/site-packages/urwid/listbox.py", line 985, in keypress
    key = focus_widget.keypress((maxcol,),key)
  File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 535, in keypress
    self._emit('click')
  File "/usr/lib/python3.5/site-packages/urwid/widget.py", line 463, in _emit
    signals.emit_signal(self, name, self, *args)
  File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 264, in emit
    result |= self._call_callback(callback, user_arg, user_args, args)
  File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 294, in _call_callback
    return bool(callback(*args_to_pass))
  File "/usr/lib/python3.5/site-packages/ncTelegram/ui_chanwidget.py", line 176, in chan_change
    self.Telegram_ui.msg_widget.get_history()
  File "/usr/lib/python3.5/site-packages/ncTelegram/ui_msgwidget.py", line 51, in get_history
    self.print_msg(msg)
  File "/usr/lib/python3.5/site-packages/ncTelegram/ui_msgwidget.py", line 98, in print_msg
    image = self.get_inline_img(msg)
  File "/usr/lib/python3.5/site-packages/ncTelegram/ui_msgwidget.py", line 243, in get_inline_img
    path = self.Telegram_ui.download_media(msg)
  File "/usr/lib/python3.5/site-packages/ncTelegram/__init__.py", line 158, in download_media
    file = self.sender.load_document(mid)
  File "/usr/lib/python3.5/site-packages/pytg/sender.py", line 630, in command_alias
    return self.execute_function(command_name, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pytg/sender.py", line 351, in execute_function
    return result_parser(message)
  File "/usr/lib/python3.5/site-packages/pytg/result_parser.py", line 74, in downloaded_file
    raise IllegalResponseException("Has no valid event attribute.")
pytg.exceptions.IllegalResponseException: Has no valid event attribute.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.5/subprocess.py", line 1072, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.5/subprocess.py", line 1700, in _communicate
    input_view = memoryview(self._input)
TypeError: memoryview: a bytes-like object is required, not 'str'

Not sure if this is a bug in nctelegram or one of the other libraries... Luckily, this buffer is the one where I can send messages to myself, so I guess it's not real crucial. I'm using the nctelegram-git package in Arch

Nanoseb commented 8 years ago

Hi, Thanks for reporting this issue. This error seems to come from a the library pytg (or more likely directly from telegram-cli). I can probably 'fix' it by handling this error. I don't have much time right now to do that, but I'll try. To circumvent that error you can set inline_image = False in the configuration file since this appends when a file is being downloaded.