mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
darkirc: truncate PRIVMSGs longer than 512
This commit is contained in:
@@ -40,7 +40,7 @@ use smol::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
server::{IrcServer, MAX_NICK_LEN},
|
||||
server::{IrcServer, MAX_MSG_LEN, MAX_NICK_LEN},
|
||||
NickServ, Privmsg, SERVER_NAME,
|
||||
};
|
||||
|
||||
@@ -413,6 +413,9 @@ impl Client {
|
||||
let channel = args.split_ascii_whitespace().next().unwrap().to_string();
|
||||
let msg_offset = args.find(':').unwrap() + 1;
|
||||
let (_, msg) = args.split_at(msg_offset);
|
||||
|
||||
// Truncate messages longer than MAX_MSG_LEN
|
||||
let msg = if msg.len() > MAX_MSG_LEN { msg.split_at(MAX_MSG_LEN).0 } else { msg };
|
||||
let mut privmsg =
|
||||
Privmsg { channel, nick: self.nickname.read().await.to_string(), msg: msg.to_string() };
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ use crate::{
|
||||
/// Max channel/nick length
|
||||
pub const MAX_NICK_LEN: usize = 24;
|
||||
|
||||
/// Max message length
|
||||
pub const MAX_MSG_LEN: usize = 512;
|
||||
|
||||
/// IRC server instance
|
||||
pub struct IrcServer {
|
||||
/// DarkIrc instance
|
||||
|
||||
Reference in New Issue
Block a user