mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-07-01 14:02:59 +03:00
feat: avatars!!!!!
This commit is contained in:
parent
6297157db0
commit
5eca8e66b6
@ -956,7 +956,7 @@ fn on_add_message(ctx: Arc<Context>, ui: &UiModel, message: String, notify: bool
|
||||
|
||||
let mut label = String::new();
|
||||
|
||||
if let (true, Some((date, ip, content, nick))) =
|
||||
if let (true, Some((date, ip, content, nick, avatar))) =
|
||||
(formatting_enabled, parse_message(message.clone()))
|
||||
{
|
||||
if let Some(ip) = ip {
|
||||
|
@ -34,6 +34,7 @@ lazy_static! {
|
||||
|
||||
pub static ref DATE_REGEX: Regex = Regex::new(r"\[(.*?)\] (.*)").unwrap();
|
||||
pub static ref IP_REGEX: Regex = Regex::new(r"\{(.*?)\} (.*)").unwrap();
|
||||
pub static ref AVATAR_REGEX: Regex = Regex::new(r"(.*) !!AR!!(.*)").unwrap();
|
||||
|
||||
pub static ref DEFAULT_USER_AGENT: Regex = Regex::new(r"<(.*?)> (.*)").unwrap();
|
||||
|
||||
@ -256,10 +257,16 @@ pub fn sanitize_message(message: String) -> Option<String> {
|
||||
Some(message)
|
||||
}
|
||||
|
||||
/// message -> (date, ip, text, (name, color))
|
||||
/// message -> (date, ip, text, (name, color), avatar)
|
||||
pub fn parse_message(
|
||||
message: String,
|
||||
) -> Option<(String, Option<String>, String, Option<(String, String)>)> {
|
||||
) -> Option<(
|
||||
String,
|
||||
Option<String>,
|
||||
String,
|
||||
Option<(String, String)>,
|
||||
Option<String>,
|
||||
)> {
|
||||
if message.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@ -297,7 +304,16 @@ pub fn parse_message(
|
||||
(message, None)
|
||||
};
|
||||
|
||||
Some((date, ip, message, nick))
|
||||
let (message, avatar) = if let Some(message) = AVATAR_REGEX.captures(&message) {
|
||||
(
|
||||
message.get(1)?.as_str().to_string(),
|
||||
Some(message.get(2)?.as_str().to_string()),
|
||||
)
|
||||
} else {
|
||||
(message, None)
|
||||
};
|
||||
|
||||
Some((date, ip, message, nick, avatar))
|
||||
}
|
||||
|
||||
// message -> (nick, content, color)
|
||||
|
Loading…
x
Reference in New Issue
Block a user