Skip to content

Commit

Permalink
Support edit_history_tweet_ids and edit_controls Tweet fields
Browse files Browse the repository at this point in the history
Resolves #1979
  • Loading branch information
Harmon758 committed Oct 7, 2022
1 parent 5ade386 commit 73c05d0
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tweepy/tweet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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")

Expand All @@ -129,6 +134,15 @@ def __init__(self, data):
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")

Expand Down

0 comments on commit 73c05d0

Please sign in to comment.