From 73c05d051fc14b00271067f005ca42f2b68304c9 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 7 Oct 2022 17:30:01 -0500 Subject: [PATCH] Support edit_history_tweet_ids and edit_controls Tweet fields Resolves #1979 --- tweepy/tweet.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tweepy/tweet.py b/tweepy/tweet.py index 694191c..0aa6c09 100644 --- a/tweepy/tweet.py +++ b/tweepy/tweet.py @@ -34,6 +34,7 @@ class Tweet(HashableID, DataMapping): text : str The actual UTF-8 text of the Tweet. See `twitter-text`_ for details on what characters are currently considered valid. + edit_history_tweet_ids : list[int] attachments : dict | None Specifies the type of attachments (if any) present in this Tweet. author_id : int | None @@ -45,6 +46,7 @@ class Tweet(HashableID, DataMapping): direct replies, replies of replies). created_at : datetime.datetime | None Creation time of the Tweet. + edit_controls : dict | None entities : dict | None Entities which have been parsed out of the text of the Tweet. Additionally see entities in Twitter Objects. @@ -100,18 +102,21 @@ class Tweet(HashableID, DataMapping): """ __slots__ = ( - "data", "id", "text", "attachments", "author_id", - "context_annotations", "conversation_id", "created_at", "entities", - "geo", "in_reply_to_user_id", "lang", "non_public_metrics", - "organic_metrics", "possibly_sensitive", "promoted_metrics", - "public_metrics", "referenced_tweets", "reply_settings", "source", - "withheld" + "data", "id", "text", "edit_history_tweet_ids", "attachments", + "author_id", "context_annotations", "conversation_id", "created_at", + "edit_controls", "entities", "geo", "in_reply_to_user_id", "lang", + "non_public_metrics", "organic_metrics", "possibly_sensitive", + "promoted_metrics", "public_metrics", "referenced_tweets", + "reply_settings", "source", "withheld" ) def __init__(self, data): self.data = data self.id = int(data["id"]) self.text = data["text"] + self.edit_history_tweet_ids = list( + map(int, data["edit_history_tweet_ids"]) + ) self.attachments = data.get("attachments") @@ -129,6 +134,15 @@ class Tweet(HashableID, DataMapping): if self.created_at is not None: self.created_at = parse_datetime(self.created_at) + self.edit_controls = data.get("edit_controls") + if self.edit_controls is not None: + self.edit_controls["edits_remaining"] = int( + self.edit_controls["edits_remaining"] + ) + self.edit_controls["editable_until"] = parse_datetime( + self.edit_controls["editable_until"] + ) + self.entities = data.get("entities") self.geo = data.get("geo") -- 2.25.1