tuna / fishroom

Message forwarding for multiple IM protocols
GNU General Public License v3.0
289 stars 58 forks source link

Crash if no gitter room #41

Closed hexchain closed 8 years ago

hexchain commented 8 years ago

config.py relevant part:

    'gitter': {
        'token': '',
        'me': '',  # bot username
    },
    'bindings': {
        "channelname": {
            "irc": '#somechannel',
            "telegram": '-12345678',
            "xmpp": ''
        }
    }
Traceback (most recent call last):
  File "/srv/http/fishroom/fishroom/fishroom.py", line 278, in wrapper
    f(*args, **kwargs)
  File "/srv/http/fishroom/fishroom/gitter.py", line 151, in GitterThread
    gt.listen_message_stream()
  File "/srv/http/fishroom/fishroom/gitter.py", line 140, in listen_message_stream
    asyncio.wait(tasks, return_when=asyncio.FIRST_EXCEPTION)
  File "/usr/lib64/python3.5/asyncio/base_events.py", line 337, in run_until_complete
    return future.result()
  File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib64/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/usr/lib64/python3.5/asyncio/tasks.py", line 332, in wait
    raise ValueError('Set of coroutines/Futures is empty.')
ValueError: Set of coroutines/Futures is empty.

If I add a gitter key to bindings:

    'bindings': {
        "channelname": {
            "irc": '#somechannel',
            "telegram": '-12345678',
            "xmpp": '',
            "gitter": ''
        }
    }

Still crash but this time a different stack trace:

Traceback (most recent call last):
  File "/srv/http/fishroom/fishroom/fishroom.py", line 278, in wrapper
    f(*args, **kwargs)
  File "/srv/http/fishroom/fishroom/gitter.py", line 151, in GitterThread
    gt.listen_message_stream()
  File "/srv/http/fishroom/fishroom/gitter.py", line 144, in listen_message_stream
    raise d.exception()
  File "/usr/lib64/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/http/fishroom/fishroom/gitter.py", line 66, in fetch
    msg = self.parse_jmsg(room, json.loads(line))
  File "/srv/http/fishroom/fishroom/gitter.py", line 76, in parse_jmsg
    from_user = jmsg['fromUser']['username']
KeyError: 'fromUser'
bigeagle commented 8 years ago

fixed.