Persist CS TOPIC so KEEPTOPIC and TOPICLOCK keep the set topic
All checks were successful
CI / check (push) Successful in 4m13s
All checks were successful
CI / check (push) Successful in 4m13s
This commit is contained in:
parent
75aa8bc096
commit
b38cde945f
1 changed files with 5 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ use echo_api::Store;
|
||||||
use echo_api::{Sender, ServiceCtx};
|
use echo_api::{Sender, ServiceCtx};
|
||||||
|
|
||||||
// TOPIC <#channel> <text>: set the channel topic (empty clears it).
|
// TOPIC <#channel> <text>: set the channel topic (empty clears it).
|
||||||
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &dyn Store) {
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db: &mut dyn Store) {
|
||||||
let Some(&chan) = args.get(1) else {
|
let Some(&chan) = args.get(1) else {
|
||||||
ctx.notice(me, from.uid, "Syntax: TOPIC <#channel> <text>");
|
ctx.notice(me, from.uid, "Syntax: TOPIC <#channel> <text>");
|
||||||
return;
|
return;
|
||||||
|
|
@ -12,5 +12,9 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
||||||
}
|
}
|
||||||
let text = if args.len() > 2 { args[2..].join(" ") } else { String::new() };
|
let text = if args.len() > 2 { args[2..].join(" ") } else { String::new() };
|
||||||
ctx.topic(me, chan, &text);
|
ctx.topic(me, chan, &text);
|
||||||
|
// Persist it too: the ircd filters our own FTOPIC back out, so without this the
|
||||||
|
// stored topic stays stale and KEEPTOPIC/TOPICLOCK restore the old one on
|
||||||
|
// recreation/restart. Ignore NoChannel (require_op already proved it exists).
|
||||||
|
let _ = db.set_channel_topic(chan, &text);
|
||||||
ctx.notice(me, from.uid, format!("Topic for \x02{chan}\x02 updated."));
|
ctx.notice(me, from.uid, format!("Topic for \x02{chan}\x02 updated."));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue