Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
19c875c18a | ||
|
12bbc0058c | ||
|
9c81806b95 | ||
|
45303005b8 | ||
|
881aa9adce | ||
|
4714be5697 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 1.9.2
|
||||
current_version = 1.9.5
|
||||
commit = True
|
||||
tag = True
|
||||
|
||||
|
@@ -13,7 +13,7 @@ from ._client import Client
|
||||
from ._util import log # TODO: Remove this (from examples too)
|
||||
|
||||
__title__ = "fbchat"
|
||||
__version__ = "1.9.2"
|
||||
__version__ = "1.9.5"
|
||||
__description__ = "Facebook Chat (Messenger) for Python"
|
||||
|
||||
__copyright__ = "Copyright 2015 - 2019 by Taehoon Kim"
|
||||
|
@@ -2271,7 +2271,17 @@ class Client(object):
|
||||
elif delta_class == "ForcedFetch":
|
||||
mid = delta.get("messageId")
|
||||
if mid is None:
|
||||
self.onUnknownMesssageType(msg=delta)
|
||||
if delta["threadKey"] is not None:
|
||||
# Looks like the whole delta is metadata in this case
|
||||
thread_id, thread_type = getThreadIdAndThreadType(delta)
|
||||
self.onPendingMessage(
|
||||
thread_id=thread_id,
|
||||
thread_type=thread_type,
|
||||
metadata=delta,
|
||||
msg=delta,
|
||||
)
|
||||
else:
|
||||
self.onUnknownMesssageType(msg=delta)
|
||||
else:
|
||||
thread_id = str(delta["threadKey"]["threadFbId"])
|
||||
fetch_info = self._forcedFetch(thread_id, mid)
|
||||
@@ -2727,6 +2737,14 @@ class Client(object):
|
||||
msg=delta,
|
||||
)
|
||||
|
||||
# New pending message
|
||||
elif delta_class == "ThreadFolder" and delta.get("folder") == "FOLDER_PENDING":
|
||||
# Looks like the whole delta is metadata in this case
|
||||
thread_id, thread_type = getThreadIdAndThreadType(delta)
|
||||
self.onPendingMessage(
|
||||
thread_id=thread_id, thread_type=thread_type, metadata=delta, msg=delta
|
||||
)
|
||||
|
||||
# Unknown message type
|
||||
else:
|
||||
self.onUnknownMesssageType(msg=delta)
|
||||
@@ -2768,9 +2786,15 @@ class Client(object):
|
||||
msg=m,
|
||||
)
|
||||
|
||||
elif topic == "jewel_requests_add":
|
||||
from_id = m["from"]
|
||||
self.onFriendRequest(from_id=from_id, msg=m)
|
||||
# Other notifications
|
||||
elif topic == "/legacy_web":
|
||||
# Friend request
|
||||
if m["type"] == "jewel_requests_add":
|
||||
from_id = m["from"]
|
||||
# TODO: from_id = str(from_id)
|
||||
self.onFriendRequest(from_id=from_id, msg=m)
|
||||
else:
|
||||
self.onUnknownMesssageType(msg=m)
|
||||
|
||||
# Chat timestamp / Buddylist overlay
|
||||
elif topic == "/orca_presence":
|
||||
@@ -2943,6 +2967,21 @@ class Client(object):
|
||||
"""
|
||||
log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name))
|
||||
|
||||
def onPendingMessage(
|
||||
self, thread_id=None, thread_type=None, metadata=None, msg=None
|
||||
):
|
||||
"""Called when the client is listening, and somebody that isn't
|
||||
connected with you on either Facebook or Messenger sends a message.
|
||||
After that, you need to use fetchThreadList to actually read the message.
|
||||
|
||||
Args:
|
||||
thread_id: Thread ID that the message was sent to. See :ref:`intro_threads`
|
||||
thread_type (ThreadType): Type of thread that the message was sent to. See :ref:`intro_threads`
|
||||
metadata: Extra metadata about the message
|
||||
msg: A full set of the data received
|
||||
"""
|
||||
log.info("New pending message from {}".format(thread_id))
|
||||
|
||||
def onColorChange(
|
||||
self,
|
||||
mid=None,
|
||||
|
@@ -74,8 +74,8 @@ class Mqtt(object):
|
||||
def _on_message_handler(self, client, userdata, message):
|
||||
# Parse payload JSON
|
||||
try:
|
||||
j = _util.parse_json(message.payload)
|
||||
except _exception.FBchatFacebookError:
|
||||
j = _util.parse_json(message.payload.decode("utf-8"))
|
||||
except (_exception.FBchatFacebookError, UnicodeDecodeError):
|
||||
log.exception("Failed parsing MQTT data on %s as JSON", message.topic)
|
||||
return
|
||||
|
||||
|
Reference in New Issue
Block a user