Skip to content

Commit

Permalink
feat(dm): ✨ Add support for the DM block API
Browse files Browse the repository at this point in the history
  • Loading branch information
MerleLiuKun committed Oct 29, 2024
1 parent 4a0885a commit 402bd8c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pytwitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,34 @@ def unblock_user(self, user_id: str, target_user_id: str) -> dict:
data = self._parse_response(resp)
return data

def block_user_dm(self, target_user_id: str):
"""
Allows the authenticated user to block direct messages (DMs) from the target user.
:param target_user_id: target user id
:return: blocked status
"""
resp = self._request(
url=f"{self.BASE_URL_V2}/users/{target_user_id}/dm/block",
verb="POST",
)
data = self._parse_response(resp)
return data


def unblock_user_dm(self, target_user_id: str):
"""
Allows the authenticated user to unblock direct messages (DMs) from the target user.
:param target_user_id: target user id
:return: unblocked status
"""
resp = self._request(
url=f"{self.BASE_URL_V2}/users/{target_user_id}/dm/unblock",
verb="POST",
)
data = self._parse_response(resp)
return data


def get_user_muting(
self,
user_id: str,
Expand Down

0 comments on commit 402bd8c

Please sign in to comment.