Skip to content

Commit

Permalink
Enable previews even when tweet has a url
Browse files Browse the repository at this point in the history
  • Loading branch information
dracarys18 committed Apr 12, 2022
1 parent 1ca581b commit 0864655
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/stream/stream_impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::config::Config;
use crate::error::TweetResult;
use crate::utils::{get_tweet_url, tweet_has_media};
use crate::utils::{get_tweet_url, tweet_has_media, tweet_has_url};
use egg_mode::stream::{filter, StreamMessage};
use futures::TryStreamExt;
use teloxide::prelude2::*;
Expand All @@ -27,7 +27,7 @@ pub async fn stream_tweets(config: &Config, to_follow: &[u64]) -> TweetResult<()
&& (to_follow.contains(&_user_id))
&& tweet.in_reply_to_user_id.unwrap().eq(&_user_id))
{
let preview = !tweet_has_media(&tweet).await;
let preview = !tweet_has_media(&tweet).await || tweet_has_url(&tweet).await;
let contains_keyword = text
.to_lowercase()
.split_whitespace()
Expand Down
4 changes: 3 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub async fn get_tweet_url(tweet: &Tweet) -> Option<String> {
screen_name, tweet_id
))
}

pub async fn tweet_has_url(tweet: &Tweet) -> bool {
!tweet.entities.urls.is_empty()
}
pub async fn get_url_entity(tweet: &Tweet) -> Option<String> {
let urls = tweet.entities.urls.clone();
if urls.is_empty() {
Expand Down

0 comments on commit 0864655

Please sign in to comment.