diff --git a/fbchat/__init__.py b/fbchat/__init__.py index 009cf57..78e55af 100644 --- a/fbchat/__init__.py +++ b/fbchat/__init__.py @@ -17,7 +17,7 @@ from .client import * __copyright__ = 'Copyright 2015 - {} by Taehoon Kim'.format(datetime.now().year) -__version__ = '1.0.16' +__version__ = '1.0.17' __license__ = 'BSD' __author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart' __email__ = 'carpedm20@gmail.com' diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 71462b0..f149a45 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -47,17 +47,18 @@ def get_customization_info(thread): for k in info.get('participant_customizations', []): rtn['nicknames'][k['participant_id']] = k.get('nickname') elif info.get('participant_customizations'): - _id = thread.get('thread_key', {}).get('other_user_id') or thread.get('id') - if len(info['participant_customizations']) > 0 and info['participant_customizations'][0]['participant_id'] == _id: - rtn['nickname'] = info['participant_customizations'][0] - if len(info['participant_customizations']) > 1: - rtn['own_nickname'] = info['participant_customizations'][1] - elif len(info['participant_customizations']) > 1 and info['participant_customizations'][1]['participant_id'] == _id: - rtn['nickname'] = info['participant_customizations'][1] - if len(info['participant_customizations']) > 1: - rtn['own_nickname'] = info['participant_customizations'][0] - else: - raise Exception('No participant matching the user {} found: {}'.format(_id, info['participant_customizations'])) + uid = thread.get('thread_key', {}).get('other_user_id') or thread.get('id') + pc = info['participant_customizations'] + if len(pc) > 0: + if pc[0].get('participant_id') == uid: + rtn['nickname'] = pc[0].get('nickname') + else: + rtn['own_nickname'] = pc[0].get('nickname') + if len(pc) > 1: + if pc[1].get('participant_id') == uid: + rtn['nickname'] = pc[1].get('nickname') + else: + rtn['own_nickname'] = pc[1].get('nickname') return rtn def graphql_to_message(message):