Compare commits

...

2 commits

Author SHA1 Message Date
ff9e3607b3 feat: add twitter video embed fixes 2024-09-28 18:39:32 +02:00
08e6e91b1c chore: updated dependencies 2024-09-28 18:39:05 +02:00
4 changed files with 806 additions and 631 deletions

1393
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,18 +7,18 @@ edition = "2021"
[dependencies]
rand = "0.8.5"
anyhow = "1.0.71"
tokio-cron-scheduler = "0.10.0"
anyhow = "1.0.89"
tokio-cron-scheduler = "0.13.0"
dotenv = "0.15.0"
# poise = "0.5.5"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http", "cache"] }
serenity_utils = "0.7.0"
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
regex = "1.9.0"
chrono = "0.4.31"
sqlx = {version="0.7.3", features=["runtime-tokio", "sqlite"]}
serenity = { version = "0.12.2", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "http", "cache"] }
# serenity_utils = "0.7.0"
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
regex = "1.10.6"
chrono = "0.4.38"
sqlx = {version="0.8.2", features=["runtime-tokio", "sqlite"]}
json = "0.12.4"
reqwest = "0.11.24"
reqwest = "0.12.7"
form_urlencoded = "1.2.1"
[features]

View file

@ -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(_) => {},

View file

@ -1,10 +1,16 @@
use std::sync::Arc;
use serenity::{all::{GuildId, ChannelId}, http::Http};
use serenity::{all::{ChannelId, CreateMessage, GuildId, Message}, http::Http};
use anyhow::Context;
pub async fn get_system_channel(guild_id: GuildId, http: Arc<Http>) -> anyhow::Result<ChannelId> {
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;
}