diff --git a/conf/config.yaml b/conf/config.yaml index fad0d0e..f9987cd 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 121 - name: 2.3.1 \ No newline at end of file + code: 122 + name: 2.3.2 \ No newline at end of file diff --git a/core/callback.py b/core/callback.py index 0ea4a72..58cb4bf 100644 --- a/core/callback.py +++ b/core/callback.py @@ -181,7 +181,7 @@ class CallBack(): else: if thread_type == ThreadType.GROUP: body['roomSender'] = author_id - + print(message_object) if message_object.text: body['content'] = message_object.text self._notify_(type_="textMsg", client=client, body=body) @@ -225,6 +225,7 @@ class CallBack(): self._notify_(type_="stickerMsg", client=client, body=body) else: print(message_object) + self.onUnknownMesssageType(client=client, msg=msg) if not self.queue: client.markAsDelivered(thread_id, message_object.uid) @@ -1126,6 +1127,11 @@ class CallBack(): msg: A full set of the data received """ type_ = msg.get('type') + try: + lwa_type = msg['attachments'][0]['mercury']['extensible_attachment']['story_attachment']['target'][ + 'lwa_type'] + except: + lwa_type = None if type_ == 'jewel_friending_notifs': self.onFriendConfirmRequest(client) @@ -1133,6 +1139,8 @@ class CallBack(): self.onAdminTextMessage(client, msg) elif type_ == 'live_poke': self.onLivePoke(client, msg) + elif lwa_type == 'WAVE': + self.onWavePoke(client, msg) else: log.debug("message : {}".format(msg)) @@ -1186,6 +1194,25 @@ class CallBack(): } self._notify_(type_="systemMsg", client=client, body=body) + def onWavePoke(self, client, msg): + messageMetadata = msg['messageMetadata'] + attachments = msg['attachments'][0] + image = attachments['mercury']['extensible_attachment']['story_attachment']['media']['image'] + description = attachments['mercury']['extensible_attachment']['story_attachment']['description'] + title_with_entities = attachments['mercury']['extensible_attachment']['story_attachment']['title_with_entities'] + body = { + 'to': client.uid, + 'from': messageMetadata['actorFbId'], + 'content': title_with_entities['text'], + 'image': image, + 'description': description['text'], + 'wave_time': messageMetadata['timestamp'], + 'type': 'wave_poke', + 'class': 'LightweightAction', + 'msgId': messageMetadata['messageId'] + } + self._notify_(type_="systemMsg", client=client, body=body) + def onWebNotice(self, client, kwargs): self._notify_(type_="webNotice", client=client, body=kwargs) if kwargs['notif_type'] == 'family_request': diff --git a/core/command.py b/core/command.py index d6dc229..a5046f8 100644 --- a/core/command.py +++ b/core/command.py @@ -259,4 +259,3 @@ class Executor(): item['type'] = 'unknown' list_msg.append(item) return list_msg - diff --git a/lib/facebook.py b/lib/facebook.py index f70c79b..41fecf0 100644 --- a/lib/facebook.py +++ b/lib/facebook.py @@ -25,8 +25,6 @@ import retrying from bs4 import BeautifulSoup from fbchat import (Client, FBchatException, FBchatUserError, Message, Sticker, ThreadType, _exception, _graphql, _util, log) -from furl import furl - from lib import common, download, google_map, graph from lib._mqtt import MqttClient from lib.common import College, WorkPlace @@ -2028,7 +2026,7 @@ class FacebookClient(Client): pic_id = li.attrs.get('data-fbid', None) url = li.attrs.get('data-starred-src', None) label = li.a.attrs.get('aria-label', None) - set_id = furl(li.a.attrs['href']).args.get('set', None) + set_id = furl.furl(li.a.attrs['href']).args.get('set', None) data = { 'pic_id': pic_id, 'set_id': set_id, @@ -2070,7 +2068,7 @@ class FacebookClient(Client): pic_id = li.attrs.get('data-fbid', None) url = li.attrs.get('data-starred-src', None) label = li.a.attrs.get('aria-label', None) - set_id = furl(li.a.attrs['href']).args.get('set', None) + set_id = furl.furl(li.a.attrs['href']).args.get('set', None) data = { 'pic_id': pic_id, 'set_id': set_id,