From 82496b8e043aa3e3c7d8513b8c10500e33da40de Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 26 Jun 2017 17:02:32 +0200 Subject: [PATCH] Minor fixes --- fbchat/__init__.py | 2 +- fbchat/client.py | 6 +++--- fbchat/graphql.py | 2 +- fbchat/models.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fbchat/__init__.py b/fbchat/__init__.py index 4536c13..232b7b8 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.4' +__version__ = '1.0.5' __license__ = 'BSD' __author__ = 'Taehoon Kim; Moreels Pieter-Jan; Mads Marquart' __email__ = 'carpedm20@gmail.com' diff --git a/fbchat/client.py b/fbchat/client.py index 9acab63..c17e6f8 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -739,7 +739,7 @@ class Client(object): raise Exception('A thread was not in participants: {}'.format(j['payload'])) entries.append(participants[k['other_user_fbid']]) elif k['thread_type'] == 2: - entries.append(Group(k['thread_fbid'], participants=[p.strip('fbid:') for p in k['participants']], photo=k['image_src'], name=k['name'])) + entries.append(Group(k['thread_fbid'], participants=set([p.strip('fbid:') for p in k['participants']]), photo=k['image_src'], name=k['name'])) else: raise Exception('A thread had an unknown thread type: {}'.format(k)) @@ -1288,7 +1288,7 @@ class Client(object): # Color change elif delta_type == "change_thread_theme": - new_color = ThreadColor(delta["untypedData"]["theme_color"]) + new_color = graphql_color_to_enum(delta["untypedData"]["theme_color"]) thread_id, thread_type = getThreadIdAndThreadType(metadata) self.onColorChange(mid=mid, author_id=author_id, new_color=new_color, thread_id=thread_id, thread_type=thread_type, ts=ts, metadata=metadata, msg=m) @@ -1350,7 +1350,7 @@ class Client(object): threads = [getThreadIdAndThreadType({"threadKey": thr}) for thr in delta.get("threadKeys")] # thread_id, thread_type = getThreadIdAndThreadType(delta) - self.onMarkedSeen(threads=threads, seen_ts=seen_ts, delivered_ts=delivered_ts, metadata=delta, msg=m) + self.onMarkedSeen(threads=threads, seen_ts=seen_ts, ts=delivered_ts, metadata=delta, msg=m) continue # New message diff --git a/fbchat/graphql.py b/fbchat/graphql.py index d9e260b..74060e6 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -102,7 +102,7 @@ def graphql_to_group(group): c_info = get_customization_info(group) return Group( group['thread_key']['thread_fbid'], - participants=[node['messaging_actor']['id'] for node in group['all_participants']['nodes']], + participants=set([node['messaging_actor']['id'] for node in group['all_participants']['nodes']]), nicknames=c_info.get('nicknames'), color=c_info.get('color'), emoji=c_info.get('emoji'), diff --git a/fbchat/models.py b/fbchat/models.py index 070e890..b1fbbf0 100644 --- a/fbchat/models.py +++ b/fbchat/models.py @@ -66,8 +66,8 @@ class User(Thread): class Group(Thread): - #: List of the group thread's participant user IDs - participants = list + #: Unique list (set) of the group thread's participant user IDs + participants = set #: Dict, containing user nicknames mapped to their IDs nicknames = dict #: A :class:`ThreadColor`. The groups's message color @@ -75,7 +75,7 @@ class Group(Thread): #: The groups's default emoji emoji = str - def __init__(self, uid, participants=[], nicknames=[], color=None, emoji=None, **kwargs): + def __init__(self, uid, participants=set(), nicknames=[], color=None, emoji=None, **kwargs): """Represents a Facebook group. Inherits `Thread`""" super(Group, self).__init__(ThreadType.GROUP, uid, **kwargs) self.participants = participants