diff --git a/src/discord_irc.rs b/src/discord_irc.rs index 6f54615..445c7d9 100644 --- a/src/discord_irc.rs +++ b/src/discord_irc.rs @@ -1,5 +1,6 @@ use crate::{ - regex, ChannelMappingKey, MembersKey, OptionReplacer, OptionStringKey, SenderKey, UserIdKey, + regex, ChannelMappingKey, MembersKey, OptionReplacer, OptionStringKey, RefContentLimitKey, + SenderKey, UserIdKey, }; use ellipse::Ellipse; use fancy_regex::{Captures, Replacer}; @@ -115,6 +116,7 @@ impl EventHandler for Handler { .as_deref() .unwrap_or("++"); let mapping = ctx_data.get::().unwrap().clone(); + let ref_content_limit = ctx_data.get::().unwrap(); if user_id == msg.author.id || msg.author.bot { return; @@ -153,7 +155,7 @@ impl EventHandler for Handler { { if let Ok(mut reply) = channel_id.message(&ctx, message_id).await { reply.guild_id = guild_id; // lmao - let (reply_prefix, _) = create_prefix(&reply, true, &ctx).await; + let (reply_prefix, reply_content_limit) = create_prefix(&reply, true, &ctx).await; let mut content = reply.content; content = content.replace("\r\n", " "); // just in case @@ -163,10 +165,14 @@ impl EventHandler for Handler { content = discord_to_irc_processing(&content, &**members_lock, &ctx, &roles).await; - let to_send = (&*content).truncate_ellipse(40); // limit taken from discord + let to_send = (&*content).truncate_ellipse( + ref_content_limit + .map(|l| l as usize) + .unwrap_or(reply_content_limit), + ); sender - .send_privmsg(channel, &format!("{}{}", reply_prefix, to_send)) + .send_privmsg(channel, format!("{}{}", reply_prefix, to_send)) .unwrap(); } } diff --git a/src/main.rs b/src/main.rs index 9460bee..2dd11da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,7 @@ struct DircordConfig { raw_prefix: Option, channels: HashMap, webhooks: Option>, + ref_content_limit: Option, } macro_rules! type_map_key { @@ -60,6 +61,7 @@ type_map_key!( StringKey => String, OptionStringKey => Option, ChannelMappingKey => HashMap, + RefContentLimitKey => Option, ); #[cfg(unix)] @@ -135,6 +137,7 @@ async fn main() -> anyhow::Result<()> { data.insert::(members.clone()); data.insert::(conf.raw_prefix); data.insert::((*channels).clone()); + data.insert::(conf.ref_content_limit); } let mut webhooks_transformed: HashMap = HashMap::new();