Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnsAnns committed Mar 19, 2024
1 parent 9edc68a commit a30e991
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 38 deletions.
10 changes: 3 additions & 7 deletions sphene/src/commands/convert_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ use poise::serenity_prelude::{CreateSelectMenuOption, Message};
use thorium::db::DBConn;
use tokio::sync::Mutex;

use poise::serenity_prelude::{
Context, CreateActionRow, CreateAllowedMentions, CreateMessage,
CreateSelectMenu, CreateSelectMenuKind,
MessageBuilder, UserId,
};
use rust_i18n::t;


use thorium::{bluesky, instagram, tiktok, twitter};

use crate::{
Expand Down Expand Up @@ -64,7 +60,7 @@ pub async fn convert_twitter_to(url: String, kind: &str) -> String {
_ => twitter::UrlType::Unknown,
};

let mut new_msg =
let new_msg =
twitter::convert_url_lazy(url.to_string(), twitter_urltype).await;

format!(
Expand Down
9 changes: 2 additions & 7 deletions sphene/src/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ pub async fn event_handler(
FullEvent::Message { new_message } => {
message_event::message(ctx, new_message.clone(), &data.db).await;
}
FullEvent::InteractionCreate { interaction } => {
match interaction {
Interaction::Component(component) => {
interaction_event::interaction_create(ctx, component.clone(), &data.db).await;
}
_ => {}
}
FullEvent::InteractionCreate { interaction: Interaction::Component(component) } => {
interaction_event::interaction_create(ctx, component.clone(), &data.db).await;
}
_ => {}
}
Expand Down
27 changes: 9 additions & 18 deletions sphene/src/message_handler/interaction_event.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@


use poise::serenity_prelude::{
ComponentInteraction, ComponentInteractionDataKind, Context, CreateActionRow, CreateAllowedMentions, CreateInteractionResponse, CreateInteractionResponseFollowup, CreateInteractionResponseMessage, EditInteractionResponse, EditMessage
ComponentInteraction, ComponentInteractionDataKind, Context, CreateAllowedMentions, CreateInteractionResponse, CreateInteractionResponseFollowup, CreateInteractionResponseMessage, EditInteractionResponse, EditMessage
};
use rust_i18n::t;
use thorium::{bluesky, db::DBConn, instagram, tiktok, twitter};
use tokio::sync::Mutex;

use crate::utils::{REGEX_URL_EXTRACTOR};
use crate::{commands::convert_url::convert_twitter_to, utils::REGEX_URL_EXTRACTOR};

pub async fn interaction_create(ctx: &Context, component: ComponentInteraction, dbconn: &Mutex<DBConn>) {
let command = match &component.data.kind {
ComponentInteractionDataKind::StringSelect { values, .. } => values[0].as_str(),
_ => return (),
_ => return ,
};

let mut msg = &component.message;
let msg = &component.message;

if !msg.author.bot {
return;
Expand Down Expand Up @@ -145,7 +145,7 @@ pub async fn interaction_create(ctx: &Context, component: ComponentInteraction,
.to_string();
let mut new_msg: String = String::new();

let mut twitter_urltype = twitter::UrlType::from_string(command);
let twitter_urltype = twitter::UrlType::from_string(command);
let bluesky_urltype = bluesky::UrlType::from_string(command);
let instagram_urltype = instagram::UrlType::from_string(command);
let tiktok_urltype = tiktok::UrlType::from_string(command);
Expand All @@ -159,19 +159,10 @@ pub async fn interaction_create(ctx: &Context, component: ComponentInteraction,
} else if tiktok_urltype != tiktok::UrlType::Unknown {
new_msg = tiktok::convert_url_lazy(extracted_url, tiktok_urltype).await;
} else if command == "direct_vx" || command == "direct_fx" {
twitter_urltype = match command {
"direct_vx" => twitter::UrlType::Vxtwitter,
"direct_fx" => twitter::UrlType::Fxtwitter,
_ => twitter::UrlType::Unknown,
};

new_msg =
twitter::convert_url_lazy(extracted_url.to_string(), twitter_urltype).await;
new_msg = format!(
"<{}> ({})",
new_msg,
twitter::get_media_from_url(new_msg.clone()).await
);
new_msg = convert_twitter_to(
extracted_url.to_string(),
command,
).await
} else if command == "direct_fxbsky" {
new_msg = bluesky::convert_url_lazy(
extracted_url.to_string(),
Expand Down
10 changes: 4 additions & 6 deletions sphene/src/message_handler/message_event.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use std::convert;


use poise::serenity_prelude::{
Context, CreateActionRow, CreateAllowedMentions, CreateMessage,
CreateSelectMenu, CreateSelectMenuKind, CreateSelectMenuOption, Message,
CreateSelectMenu, CreateSelectMenuKind, Message,
MessageBuilder, UserId,
};
use rust_i18n::t;
use thorium::{bluesky, db::DBConn, instagram, tiktok, twitter};
use thorium::{db::DBConn};
use tokio::sync::Mutex;

use crate::{
commands::convert_url::convert_url, options::{
get_blueksy_options, get_instagram_options, get_tik_tok_options, get_twitter_options,
}
commands::convert_url::convert_url
};

pub async fn message(context: &Context, msg: Message, dbconn: &Mutex<DBConn>) {
Expand Down

0 comments on commit a30e991

Please sign in to comment.