Terrance/SkPy

AttributeError: 'NoneType' object has no attribute 'get'

Closed this issue · 1 comments

For the last couple days, I'm getting an error when trying to get messages from skype.

Traceback (most recent call last):
    msgs = chat.getMsgs()
  File "/var/www/user/data/.local/lib/python2.7/site-packages/skpy/chat.py", line 72, in getMsgs
    return [SkypeMsg.fromRaw(self.skype, json) for json in resp.get("messages", [])]
  File "/var/www/user/data/.local/lib/python2.7/site-packages/skpy/msg.py", line 254, in fromRaw
    return msgCls(skype, raw, **msgCls.rawToFields(raw))
  File "/var/www/user/data/.local/lib/python2.7/site-packages/skpy/msg.py", line 663, in rawToFields
    "missed": cls.State.Missed}.get(listTag.get("type")),
AttributeError: 'NoneType' object has no attribute 'get'

Also, I found what causes this problem. I'm getting a response with a message that has an empty 'content' field, so the library can't find 'partlist' from that field and that leads to the problem when we can't get a type from the 'listTag'. Below I listed the response with that message.

Api response

{
  "messages": [
    {
      "id": "1511743273312",
      "originalarrivaltime": "2021-01-27T10:27:53.312Z",
      "messagetype": "Event/Call",
      "version": "1611749044640",
      "composetime": "2021-01-27T10:27:53.312Z",
      "skypeeditedid": "12521848445089248933",
      "skypeguid": "1f240736-d4e2-4ada-9486-a0da27425056",
      "content": "",
      "conversationLink": "https://azwcus1-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:live:zxcasdqw",
      "conversationid": "8:live:zxcasdqw",
      "type": "Message",
      "from": "https://azwcus1-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:live:zxcasdqw"
    }
  ]
}

Duplicate of #163 which applied to all message types, fixed on master and 0.10.3.