BotServ: richer INFO
INFO <#channel> now lists the BotServ options in effect (greets, kickers, nobot) alongside the assigned bot; INFO <bot> flags a private bot.
This commit is contained in:
parent
5bc41f2e60
commit
0e90dd8020
3 changed files with 19 additions and 2 deletions
|
|
@ -393,6 +393,8 @@ pub struct ChannelView {
|
||||||
pub bot_greet: bool,
|
pub bot_greet: bool,
|
||||||
// BotServ: whether the founder is barred from (un)assigning a bot.
|
// BotServ: whether the founder is barred from (un)assigning a bot.
|
||||||
pub nobot: bool,
|
pub nobot: bool,
|
||||||
|
// BotServ: whether any message kicker is active on this channel.
|
||||||
|
pub kickers_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// A single ChanServ SET option, named for the typed `set_channel_setting` call.
|
// A single ChanServ SET option, named for the typed `set_channel_setting` call.
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,23 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
||||||
ctx.notice(me, from.uid, format!("\x02{target}\x02 isn't registered."));
|
ctx.notice(me, from.uid, format!("\x02{target}\x02 isn't registered."));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
match chan.assigned_bot {
|
match &chan.assigned_bot {
|
||||||
Some(bot) => ctx.notice(me, from.uid, format!("\x02{target}\x02 is served by bot \x02{bot}\x02.")),
|
Some(bot) => ctx.notice(me, from.uid, format!("\x02{target}\x02 is served by bot \x02{bot}\x02.")),
|
||||||
None => ctx.notice(me, from.uid, format!("\x02{target}\x02 has no bot assigned. Assign one with \x02ASSIGN\x02 {target} <bot>.")),
|
None => ctx.notice(me, from.uid, format!("\x02{target}\x02 has no bot assigned. Assign one with \x02ASSIGN\x02 {target} <bot>.")),
|
||||||
}
|
}
|
||||||
|
// The BotServ options in effect on this channel.
|
||||||
|
let mut opts = Vec::new();
|
||||||
|
if chan.bot_greet {
|
||||||
|
opts.push("greets");
|
||||||
|
}
|
||||||
|
if chan.kickers_active {
|
||||||
|
opts.push("kickers");
|
||||||
|
}
|
||||||
|
if chan.nobot {
|
||||||
|
opts.push("nobot");
|
||||||
|
}
|
||||||
|
let summary = if opts.is_empty() { "none".to_string() } else { opts.join(", ") };
|
||||||
|
ctx.notice(me, from.uid, format!(" Options: {summary}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,7 +44,8 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
||||||
.map(|c| c.name)
|
.map(|c| c.name)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
ctx.notice(me, from.uid, format!("Bot \x02{}\x02 — {}@{}", bot.nick, bot.user, bot.host));
|
let privacy = if bot.private { " (private)" } else { "" };
|
||||||
|
ctx.notice(me, from.uid, format!("Bot \x02{}\x02 — {}@{}{privacy}", bot.nick, bot.user, bot.host));
|
||||||
ctx.notice(me, from.uid, format!(" Real name: {}", bot.gecos));
|
ctx.notice(me, from.uid, format!(" Real name: {}", bot.gecos));
|
||||||
if channels.is_empty() {
|
if channels.is_empty() {
|
||||||
ctx.notice(me, from.uid, " Not assigned to any channel.");
|
ctx.notice(me, from.uid, " Not assigned to any channel.");
|
||||||
|
|
|
||||||
|
|
@ -2277,6 +2277,7 @@ fn channel_view(c: &ChannelInfo) -> ChannelView {
|
||||||
assigned_bot: c.assigned_bot.clone(),
|
assigned_bot: c.assigned_bot.clone(),
|
||||||
bot_greet: c.settings.bot_greet,
|
bot_greet: c.settings.bot_greet,
|
||||||
nobot: c.settings.nobot,
|
nobot: c.settings.nobot,
|
||||||
|
kickers_active: c.kickers.any(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue