Skip to content

Commit

Permalink
darkirc: fix minor bug that caused the topic args be cut off after fi…
Browse files Browse the repository at this point in the history
…rst word
  • Loading branch information
dasman committed Jan 25, 2025
1 parent 5ca8e47 commit f6fd56b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/darkirc/src/irc/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,11 @@ impl Client {
}

// If there's a topic, we'll set it, otherwise return the set topic.
let Some(topic) = tokens.next() else {
let full_topic = args.replacen(channel, "", 1);
let full_topic = full_topic.trim();
let topic = if !full_topic.is_empty() {
full_topic
} else {
let topic = self.server.channels.read().await.get(channel).unwrap().topic.clone();
if topic.is_empty() {
return Ok(vec![ReplyType::Server((
Expand All @@ -778,7 +782,7 @@ impl Client {

// Set the new topic
self.server.channels.write().await.get_mut(channel).unwrap().topic =
topic.strip_prefix(':').unwrap().to_string();
topic.trim().strip_prefix(':').unwrap().to_string();

// Send reply
let replies = vec![ReplyType::Client((nick, format!("TOPIC {} {}", channel, topic)))];
Expand Down

0 comments on commit f6fd56b

Please sign in to comment.