Add thread mute settings to ThreadABC
This commit is contained in:
@@ -987,66 +987,6 @@ class Client:
|
||||
j = self._payload_post("/ajax/mercury/delete_messages.php?dpr=1", data)
|
||||
return True
|
||||
|
||||
def mute_thread(self, mute_time=None, thread_id=None):
|
||||
"""Mute thread.
|
||||
|
||||
Args:
|
||||
mute_time (datetime.timedelta): Time to mute, use ``None`` to mute forever
|
||||
thread_id: User/Group ID to mute. See :ref:`intro_threads`
|
||||
"""
|
||||
if mute_time is None:
|
||||
mute_settings = -1
|
||||
else:
|
||||
mute_settings = _util.timedelta_to_seconds(mute_time)
|
||||
data = {"mute_settings": str(mute_settings), "thread_fbid": thread_id}
|
||||
j = self._payload_post("/ajax/mercury/change_mute_thread.php?dpr=1", data)
|
||||
|
||||
def unmute_thread(self, thread_id=None):
|
||||
"""Unmute thread.
|
||||
|
||||
Args:
|
||||
thread_id: User/Group ID to unmute. See :ref:`intro_threads`
|
||||
"""
|
||||
return self.mute_thread(datetime.timedelta(0), thread_id)
|
||||
|
||||
def mute_thread_reactions(self, mute=True, thread_id=None):
|
||||
"""Mute thread reactions.
|
||||
|
||||
Args:
|
||||
mute: Boolean. True to mute, False to unmute
|
||||
thread_id: User/Group ID to mute. See :ref:`intro_threads`
|
||||
"""
|
||||
data = {"reactions_mute_mode": int(mute), "thread_fbid": thread_id}
|
||||
j = self._payload_post(
|
||||
"/ajax/mercury/change_reactions_mute_thread/?dpr=1", data
|
||||
)
|
||||
|
||||
def unmute_thread_reactions(self, thread_id=None):
|
||||
"""Unmute thread reactions.
|
||||
|
||||
Args:
|
||||
thread_id: User/Group ID to unmute. See :ref:`intro_threads`
|
||||
"""
|
||||
return self.mute_thread_reactions(False, thread_id)
|
||||
|
||||
def mute_thread_mentions(self, mute=True, thread_id=None):
|
||||
"""Mute thread mentions.
|
||||
|
||||
Args:
|
||||
mute: Boolean. True to mute, False to unmute
|
||||
thread_id: User/Group ID to mute. See :ref:`intro_threads`
|
||||
"""
|
||||
data = {"mentions_mute_mode": int(mute), "thread_fbid": thread_id}
|
||||
j = self._payload_post("/ajax/mercury/change_mentions_mute_thread/?dpr=1", data)
|
||||
|
||||
def unmute_thread_mentions(self, thread_id=None):
|
||||
"""Unmute thread mentions.
|
||||
|
||||
Args:
|
||||
thread_id: User/Group ID to unmute. See :ref:`intro_threads`
|
||||
"""
|
||||
return self.mute_thread_mentions(False, thread_id)
|
||||
|
||||
"""
|
||||
LISTEN METHODS
|
||||
"""
|
||||
|
@@ -440,6 +440,53 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
||||
fb_error_message=j.get("errorMessage"),
|
||||
)
|
||||
|
||||
def mute(self, duration: datetime.timedelta = None):
|
||||
"""Mute the thread.
|
||||
|
||||
Args:
|
||||
duration: Time to mute, use ``None`` to mute forever
|
||||
"""
|
||||
if duration is None:
|
||||
setting = "-1"
|
||||
else:
|
||||
setting = str(_util.timedelta_to_seconds(duration))
|
||||
data = {"mute_settings": setting, "thread_fbid": self.id}
|
||||
j = self.session._payload_post(
|
||||
"/ajax/mercury/change_mute_thread.php?dpr=1", data
|
||||
)
|
||||
|
||||
def unmute(self):
|
||||
"""Unmute the thread."""
|
||||
return self.mute(datetime.timedelta(0))
|
||||
|
||||
def _mute_reactions(self, mode: bool):
|
||||
data = {"reactions_mute_mode": "1" if mode else "0", "thread_fbid": self.id}
|
||||
j = self.session._payload_post(
|
||||
"/ajax/mercury/change_reactions_mute_thread/?dpr=1", data
|
||||
)
|
||||
|
||||
def mute_reactions(self):
|
||||
"""Mute thread reactions."""
|
||||
self._mute_reactions(True)
|
||||
|
||||
def unmute_reactions(self):
|
||||
"""Unmute thread reactions."""
|
||||
self._mute_reactions(False)
|
||||
|
||||
def _mute_mentions(self, mode: bool):
|
||||
data = {"mentions_mute_mode": "1" if mode else "0", "thread_fbid": self.id}
|
||||
j = self.session._payload_post(
|
||||
"/ajax/mercury/change_mentions_mute_thread/?dpr=1", data
|
||||
)
|
||||
|
||||
def mute_mentions(self):
|
||||
"""Mute thread mentions."""
|
||||
self._mute_mentions(True)
|
||||
|
||||
def unmute_mentions(self):
|
||||
"""Unmute thread mentions."""
|
||||
self._mute_mentions(False)
|
||||
|
||||
def mark_as_spam(self):
|
||||
"""Mark the thread as spam, and delete it."""
|
||||
data = {"id": self.id}
|
||||
|
Reference in New Issue
Block a user