diff --git a/src/rewrite_links/check_contain_links.rs b/src/rewrite_links/check_contain_links.rs index e5edf2d..76a29de 100644 --- a/src/rewrite_links/check_contain_links.rs +++ b/src/rewrite_links/check_contain_links.rs @@ -4,11 +4,20 @@ use crate::rewrite_links::links_to_rewrite; pub fn contain_links(msg: Message) -> bool { match msg.text() { - Some(text) => links_to_rewrite::check_domains(String::from(text)), + Some(text) => links_to_rewrite::check_domains(get_domain(text)), None => false, } } +pub fn get_domain(text: &str) -> String { + let s_text = String::from(text); + let split_array = s_text.split("/").collect::>(); + if split_array[0] == String::from("https:") && split_array[1].len() == 0 { + return split_array[2].to_string(); + } + return String::new(); +} + pub async fn fix_links(msg: Message, bot: Bot) -> anyhow::Result<()> { let text = msg.text().unwrap(); let url_and_domain = links_to_rewrite::get_domain_from_text(String::from(text)); diff --git a/src/rewrite_links/links_to_rewrite.rs b/src/rewrite_links/links_to_rewrite.rs index 39ddb2a..3dafaf1 100644 --- a/src/rewrite_links/links_to_rewrite.rs +++ b/src/rewrite_links/links_to_rewrite.rs @@ -3,11 +3,11 @@ use phf::phf_map; use curl::easy::Easy; static URLS: phf::Map<&'static str, (&'static str, bool)> = phf_map! { - "www.tiktok.com" => ("vxtiktok.com", false), - "vm.tiktok.com" => ("vxtiktok.com", true), - "vt.tiktok.com" => ("vxtiktok.com", true), - "lite.tiktok.com" => ("vxtiktok.com", true), - "www.instagram.com" => ("ddinstagram.com", false), + "www.tiktok.com" => ("kktiktok.com", false), + "vm.tiktok.com" => ("kktiktok.com", true), + "vt.tiktok.com" => ("kktiktok.com", true), + "lite.tiktok.com" => ("kktiktok.com", true), + "www.instagram.com" => ("kkinstagram.com", false), "https://x.com" => ("https://fxtwitter.com", false), "https://twitter.com" => ("https://fxtwitter.com",false), };