Skip to content

Commit

Permalink
support kick
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Mar 13, 2024
1 parent 62b08fd commit bb9fd7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@ impl Client {
channel.users.insert(user);
}
}
Command::KICK(channel, victim, _) => {
if victim == self.nickname().as_ref() {
self.chanmap.remove(channel);
} else if let Some(channel) = self.chanmap.get_mut(channel) {
channel.users.remove(&User::from(Nick::from(victim.as_str())));
}
}
Command::Numeric(RPL_WHOREPLY, args) => {
let target = args.get(1)?;

Expand Down
14 changes: 14 additions & 0 deletions data/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ fn text(message: &Encoded, our_nick: &Nick, config: &Config) -> Option<String> {
)
})
}
Command::KICK(_, victim, comment) => {
let user = user?;
let comment = comment
.as_ref()
.map(|comment| format!(" ({comment})"))
.unwrap_or_default();
let target = if victim == our_nick.as_ref() {
"you have".to_string()
} else {
format!("{victim} has")
};

Some(format!("⟵ {target} been kicked by {user}{comment}"))
}
Command::MODE(target, modes, args) if proto::is_channel(target) => {
let user = user?;
let modes = modes
Expand Down

0 comments on commit bb9fd7c

Please sign in to comment.