Skip to content

Commit

Permalink
Fixed errors on unknown genders
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 15, 2017
1 parent 32c72c2 commit 4f1f9bf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fbchat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


__copyright__ = 'Copyright 2015 - {} by Taehoon Kim'.format(datetime.now().year)
__version__ = '1.1.2'
__version__ = '1.1.3'
__license__ = 'BSD'
__author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart'
__email__ = '[email protected]'
Expand Down
4 changes: 2 additions & 2 deletions fbchat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def fetchAllUsers(self):
if k['id'] in ['0', 0]:
# Skip invalid users
pass
users.append(User(k['id'], first_name=k.get('firstName'), url=k.get('uri'), photo=k.get('thumbSrc'), name=k.get('name'), is_friend=k.get('is_friend'), gender=GENDERS[k.get('gender')]))
users.append(User(k['id'], first_name=k.get('firstName'), url=k.get('uri'), photo=k.get('thumbSrc'), name=k.get('name'), is_friend=k.get('is_friend'), gender=GENDERS.get(k.get('gender'))))

return users

Expand Down Expand Up @@ -791,7 +791,7 @@ def fetchThreadList(self, offset=0, limit=20, thread_location=ThreadLocation.INB
if p['type'] == 'page':
participants[p['fbid']] = Page(p['fbid'], url=p['href'], photo=p['image_src'], name=p['name'])
elif p['type'] == 'user':
participants[p['fbid']] = User(p['fbid'], url=p['href'], first_name=p['short_name'], is_friend=p['is_friend'], gender=GENDERS[p['gender']], photo=p['image_src'], name=p['name'])
participants[p['fbid']] = User(p['fbid'], url=p['href'], first_name=p['short_name'], is_friend=p['is_friend'], gender=GENDERS.get(p['gender']), photo=p['image_src'], name=p['name'])
else:
raise FBchatException('A participant had an unknown type {}: {}'.format(p['type'], p))

Expand Down
2 changes: 1 addition & 1 deletion fbchat/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def graphql_to_user(user):
first_name=user.get('first_name'),
last_name=user.get('last_name'),
is_friend=user.get('is_viewer_friend'),
gender=GENDERS[user.get('gender')],
gender=GENDERS.get(user.get('gender')),
affinity=user.get('affinity'),
nickname=c_info.get('nickname'),
color=c_info.get('color'),
Expand Down
3 changes: 1 addition & 2 deletions fbchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@
#'': 'female_singular_guess',
#'': 'male_singular_guess',
#'': 'mixed',
#'': 'neuter_singular',
'NEUTER': 'neuter_singular',
#'': 'unknown_singular',
#'': 'female_plural',
#'': 'male_plural',
#'': 'neuter_plural',
#'': 'unknown_plural',
None: None
}

class ReqUrl(object):
Expand Down

0 comments on commit 4f1f9bf

Please sign in to comment.