pub struct DraftTweet {
pub text: Cow<'static, str>,
pub in_reply_to: Option<u64>,
pub auto_populate_reply_metadata: Option<bool>,
pub exclude_reply_user_ids: Option<Cow<'static, [u64]>>,
pub attachment_url: Option<Cow<'static, str>>,
pub coordinates: Option<(f64, f64)>,
pub display_coordinates: Option<bool>,
pub place_id: Option<Cow<'static, str>>,
pub media_ids: Vec<MediaId>,
pub possibly_sensitive: Option<bool>,
}Expand description
Represents an in-progress tweet before it is sent.
This is your entry point to posting new tweets to Twitter. To begin, make a new DraftTweet by
calling new with your desired status text:
use egg_mode::tweet::DraftTweet;
let draft = DraftTweet::new("This is an example status!");As-is, the draft won’t do anything until you call send to post it:
draft.send(&token).await.unwrap();Right now, the options for adding metadata to a post are pretty sparse. See the adaptor
functions below to see what metadata can be set. For example, you can use in_reply_to to
create a reply-chain like this:
use egg_mode::tweet::DraftTweet;
let draft = DraftTweet::new("I'd like to start a thread here.");
let tweet = draft.send(&token).await.unwrap();
let draft = DraftTweet::new("You see, I have a lot of things to say.")
.in_reply_to(tweet.id);
let tweet = draft.send(&token).await.unwrap();
let draft = DraftTweet::new("Thank you for your time.")
.in_reply_to(tweet.id);
let tweet = draft.send(&token).await.unwrap();Fields§
§text: Cow<'static, str>The text of the draft tweet.
in_reply_to: Option<u64>If present, the ID of the tweet this draft is replying to.
auto_populate_reply_metadata: Option<bool>If present, whether to automatically fill reply mentions from the metadata of the
in_reply_to tweet.
exclude_reply_user_ids: Option<Cow<'static, [u64]>>If present, the list of user IDs to exclude from the automatically-populated metadata pulled
when auto_populate_reply_metadata is true.
attachment_url: Option<Cow<'static, str>>If present, the tweet link to quote or a DM deep link to include in the tweet’s attachment metadata.
Note that if this link is not a tweet link or a DM deep link, Twitter will return an error when the draft is sent.
coordinates: Option<(f64, f64)>If present, the latitude/longitude coordinates to attach to the draft.
display_coordinates: Option<bool>If present (and if coordinates is present), indicates whether to display a pin on the
exact coordinate when the eventual tweet is displayed.
place_id: Option<Cow<'static, str>>If present the Place to attach to this draft.
media_ids: Vec<MediaId>List of media entities associated with tweet.
A tweet can have one video, one GIF, or up to four images attached to it. When attaching
them to a tweet, they’re represented by a media ID, given through the upload process. (See
the media module for more information on how to upload media.)
DraftTweet treats zeros in this array as if the media were not present.
possibly_sensitive: Option<bool>States whether the media attached with media_ids should be labeled as “possibly
sensitive”, to mask the media by default.
Implementations§
Source§impl DraftTweet
impl DraftTweet
Sourcepub fn new<S: Into<Cow<'static, str>>>(text: S) -> Self
pub fn new<S: Into<Cow<'static, str>>>(text: S) -> Self
Creates a new DraftTweet with the given status text.
Sourcepub fn in_reply_to(self, in_reply_to: u64) -> Self
pub fn in_reply_to(self, in_reply_to: u64) -> Self
Marks this draft tweet as replying to the given status ID.
Note that this will only properly take effect if the user who posted the given status is @mentioned in the status text, or if the given status was posted by the authenticated user.
Sourcepub fn auto_populate_reply_metadata(self, auto_populate: bool) -> Self
pub fn auto_populate_reply_metadata(self, auto_populate: bool) -> Self
Tells Twitter whether or not to automatically fill reply mentions from the tweet linked in
in_reply_to.
This parameter will have no effect if in_reply_to is absent.
If you set this to true, you can strip out the mentions from the beginning of the tweet text
if they were also in the reply mentions of the parent tweet. To remove handles from the list
of reply mentions, hand their user IDs to exclude_reply_user_ids.
Sourcepub fn exclude_reply_user_ids<V: Into<Cow<'static, [u64]>>>(
self,
user_ids: V,
) -> Self
pub fn exclude_reply_user_ids<V: Into<Cow<'static, [u64]>>>( self, user_ids: V, ) -> Self
Tells Twitter to exclude the given list of user IDs from the automatically-populated reply mentions.
This parameter will have no effect if auto_populate_reply_metadata is absent or false.
Note that you cannot use this parameter to remove the author of the parent tweet from the reply list. Twitter will silently ignore the author’s ID in that scenario.
Sourcepub fn attachment_url<S: Into<Cow<'static, str>>>(self, url: S) -> Self
pub fn attachment_url<S: Into<Cow<'static, str>>>(self, url: S) -> Self
Attaches the given tweet URL or DM deep link to the tweet draft, which lets it be used outside the 280 character text limit.
Note that if this link is not a tweet URL or a DM deep link, then Twitter will return an error when this draft is sent.
Sourcepub fn coordinates(self, latitude: f64, longitude: f64, display: bool) -> Self
pub fn coordinates(self, latitude: f64, longitude: f64, display: bool) -> Self
Attach a lat/lon coordinate to this tweet, and mark whether a pin should be placed on the exact coordinate when the tweet is displayed.
If coordinates are given through this method and no place_id is attached, Twitter will
effectively call place::reverse_geocode with the given coordinate and attach that Place to
the eventual tweet.
Location fields will be ignored unless the user has enabled geolocation from their profile.
Sourcepub fn place_id<S: Into<Cow<'static, str>>>(self, place_id: S) -> Self
pub fn place_id<S: Into<Cow<'static, str>>>(self, place_id: S) -> Self
Attach a Place to this tweet. This field will take precedence over coordinates in terms of
what location is displayed with the tweet.
Location fields will be ignored unless the user has enabled geolocation from their profile.
Sourcepub fn add_media(&mut self, media_id: MediaId)
pub fn add_media(&mut self, media_id: MediaId)
Attaches the given media ID(s) to this tweet. If more than four IDs are in this slice, only the first four will be attached. Note that Twitter will only allow one GIF, one video, or up to four images to be attached to a single tweet.
Note that if this is called multiple times, only the last four IDs will be kept.
Sourcepub fn possibly_sensitive(self, sensitive: bool) -> Self
pub fn possibly_sensitive(self, sensitive: bool) -> Self
Marks the media attached with media_ids as being sensitive, so it can be hidden by
default.
Trait Implementations§
Source§impl Clone for DraftTweet
impl Clone for DraftTweet
Source§fn clone(&self) -> DraftTweet
fn clone(&self) -> DraftTweet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more