feat: add twitter video embed fixes
This commit is contained in:
parent
5442802f66
commit
ce57dd1999
2 changed files with 25 additions and 1 deletions
|
@ -2,9 +2,11 @@ use rand::random;
|
|||
use serenity::http::CacheHttp;
|
||||
use serenity::{client::Context, http::Http};
|
||||
use serenity::model::channel::Message;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::util::debug::send_error;
|
||||
use crate::util::utilities;
|
||||
|
||||
use crate::commands::moove::{moove, moove_check};
|
||||
|
||||
|
@ -29,6 +31,22 @@ pub async fn handle(ctx: Context, msg: Message) {
|
|||
}
|
||||
}
|
||||
|
||||
// X and IG not embedding correctly (IG fix does not work for now need to find different one)
|
||||
let link_fixes = HashMap::from([
|
||||
("//x.com", "//fxtwitter.com")
|
||||
]);
|
||||
|
||||
for (site, fix) in link_fixes {
|
||||
if lower_case_content.contains(site) {
|
||||
let new_content = format!("Sent by {}\n{}", msg.clone().author, lower_case_content.replace(site, fix));
|
||||
match utilities::replace_msg(ctx.http.clone(), msg.clone(), new_content).await {
|
||||
Ok(_) => {},
|
||||
Err(e) => send_error(ctx.http.clone(), e.to_string()).await
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if random::<u16>() % 1000 == 666 {
|
||||
match msg.reply(ctx.http(), "Povedz loď").await {
|
||||
Ok(_) => {},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use serenity::{all::{GuildId, ChannelId}, http::Http};
|
||||
use serenity::{all::{ChannelId, CreateMessage, GuildId, Message}, http::Http};
|
||||
|
||||
use anyhow::Context;
|
||||
|
||||
|
@ -8,3 +8,9 @@ pub async fn get_system_channel(guild_id: GuildId, http: Arc<Http>) -> anyhow::R
|
|||
return http.get_guild(guild_id).await?.system_channel_id
|
||||
.context(format!("System channel of guild: {} not found", guild_id.get()));
|
||||
}
|
||||
|
||||
pub async fn replace_msg(http: Arc<Http>, msg: Message, content: String) -> Result<Message, serenity::Error> {
|
||||
msg.delete(http.clone()).await?;
|
||||
|
||||
return ChannelId::new(msg.channel_id.get()).send_message(http.clone(), CreateMessage::new().content(content)).await;
|
||||
}
|
Loading…
Reference in a new issue