Allow !dbg with a nickname
This commit is contained in:
parent
89be1c366d
commit
4e8934903e
32
src/main.rs
32
src/main.rs
|
@ -83,11 +83,33 @@ async fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
Command::PRIVMSG(ref channel, ref message) => {
|
||||
if message.starts_with("!dbg") {
|
||||
client.send_privmsg(
|
||||
nick,
|
||||
format!("{:#?}", channel_users).replace("\n", "\r\n"),
|
||||
)?;
|
||||
if let Some(mut arg) = message.strip_prefix("!dbg") {
|
||||
arg = arg.trim();
|
||||
if !arg.is_empty() {
|
||||
if let Some(h) = channel_users.get(channel) {
|
||||
client.send_privmsg(
|
||||
nick,
|
||||
format!(
|
||||
"{}: {}",
|
||||
arg,
|
||||
h.get(arg)
|
||||
.map(|v| format!("{:?}", v))
|
||||
.unwrap_or_else(|| "No such nick".into())
|
||||
)
|
||||
.replace("\n", "\r\n"),
|
||||
)?;
|
||||
} else {
|
||||
client.send_privmsg(
|
||||
nick,
|
||||
"!dbg with a nickname can only be used in a channel!",
|
||||
)?;
|
||||
}
|
||||
} else {
|
||||
client.send_privmsg(
|
||||
nick,
|
||||
format!("{:#?}", channel_users).replace("\n", "\r\n"),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
let users = unwrap_or_continue!(channel_users.get_mut(channel));
|
||||
let user = unwrap_or_continue!(users.get_mut(nick));
|
||||
|
|
Loading…
Reference in a new issue