Compare commits
2 commits
ce5b4fb2ac
...
03f0ea717a
Author | SHA1 | Date | |
---|---|---|---|
03f0ea717a | |||
a3f775222f |
4 changed files with 50 additions and 49 deletions
46
src/channel.rs
Normal file
46
src/channel.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use chrono::{DateTime, Local};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::irc_message::IrcMessage;
|
||||
|
||||
pub struct Channel {
|
||||
pub channel_name: Option<String>,
|
||||
|
||||
pub messages: Vec<IrcMessage>,
|
||||
pub message_ids: HashSet<String>,
|
||||
pub names: Vec<String>,
|
||||
pub topic: Option<String>,
|
||||
|
||||
pub unread_messages: i32,
|
||||
pub unread_highlights: i32,
|
||||
pub unread_events: i32,
|
||||
|
||||
pub is_multiline: bool,
|
||||
pub multiline_privmsgs: Option<Vec<String>>,
|
||||
pub multiline_timestamp: Option<DateTime<Local>>,
|
||||
pub multiline_nickname: Option<String>,
|
||||
pub multiline_message_id: Option<String>,
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
pub fn new(channel_name: Option<&str>) -> Self {
|
||||
Self {
|
||||
channel_name: channel_name.map(String::from),
|
||||
|
||||
messages: Vec::new(),
|
||||
message_ids: HashSet::new(),
|
||||
names: Vec::new(),
|
||||
topic: None,
|
||||
|
||||
unread_messages: 0,
|
||||
unread_highlights: 0,
|
||||
unread_events: 0,
|
||||
|
||||
is_multiline: false,
|
||||
multiline_privmsgs: None,
|
||||
multiline_timestamp: None,
|
||||
multiline_nickname: None,
|
||||
multiline_message_id: None,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -174,12 +174,7 @@ impl Cri {
|
|||
.send(
|
||||
IrcCommand::Raw(
|
||||
"CHATHISTORY".into(),
|
||||
vec![
|
||||
"LATEST".into(),
|
||||
chanlist.into(),
|
||||
"*".into(),
|
||||
100.to_string(),
|
||||
],
|
||||
vec!["LATEST".into(), chanlist.into(), "*".into(), "100".into()],
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
mod channel;
|
||||
mod cri;
|
||||
mod cri_flags;
|
||||
mod irc_handler;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{
|
||||
channel::Channel,
|
||||
irc_message::{IrcMessage, MessageDetail},
|
||||
util::{self, BATCH_SUB_COMMAND_CHATHISTORY},
|
||||
};
|
||||
|
@ -10,49 +11,7 @@ use iced::{
|
|||
Background, Color, Element, Length,
|
||||
};
|
||||
use irc::proto::BatchSubCommand;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
pub struct Channel {
|
||||
pub channel_name: Option<String>,
|
||||
|
||||
pub messages: Vec<IrcMessage>,
|
||||
pub message_ids: HashSet<String>,
|
||||
pub names: Vec<String>,
|
||||
pub topic: Option<String>,
|
||||
|
||||
pub unread_messages: i32,
|
||||
pub unread_highlights: i32,
|
||||
pub unread_events: i32,
|
||||
|
||||
pub is_multiline: bool,
|
||||
pub multiline_privmsgs: Option<Vec<String>>,
|
||||
pub multiline_timestamp: Option<chrono::DateTime<Local>>,
|
||||
pub multiline_nickname: Option<String>,
|
||||
pub multiline_message_id: Option<String>,
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
fn new(channel_name: Option<&str>) -> Self {
|
||||
Self {
|
||||
channel_name: channel_name.map(String::from),
|
||||
|
||||
messages: Vec::new(),
|
||||
message_ids: HashSet::new(),
|
||||
names: Vec::new(),
|
||||
topic: None,
|
||||
|
||||
unread_messages: 0,
|
||||
unread_highlights: 0,
|
||||
unread_events: 0,
|
||||
|
||||
is_multiline: false,
|
||||
multiline_privmsgs: None,
|
||||
multiline_timestamp: None,
|
||||
multiline_nickname: None,
|
||||
multiline_message_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct MessageLog {
|
||||
channels: HashMap<Option<String>, Channel>,
|
||||
|
|
Loading…
Reference in a new issue