html terminal
fix leaks
bendn 2023-11-02
parent b3f6d21 · commit 33c9977
-rw-r--r--src/bot/bans.rs8
-rw-r--r--src/webhook.rs8
2 files changed, 13 insertions, 3 deletions
diff --git a/src/bot/bans.rs b/src/bot/bans.rs
index e0b65d3..0938972 100644
--- a/src/bot/bans.rs
+++ b/src/bot/bans.rs
@@ -23,7 +23,8 @@ pub async fn add(
.unwrap();
send_ctx!(ctx, "ban ip {}", player.ip)?;
send_ctx!(ctx, "ban id {}", player.uuid)?;
- return_next!(ctx)
+ ctx.say(format!("banned {}", player.name)).await?;
+ Ok(())
}
#[poise::command(
@@ -35,7 +36,7 @@ pub async fn add(
/// kick somebody off the server
pub async fn kick(
ctx: Context<'_>,
- #[description = "player to ban"]
+ #[description = "player to kick"]
#[autocomplete = "player::autocomplete"]
player: String,
) -> Result<()> {
@@ -45,7 +46,8 @@ pub async fn kick(
.unwrap()
.unwrap();
send_ctx!(ctx, "kick {}", player.uuid)?; // FIXME
- return_next!(ctx)
+ ctx.say(format!("kicked {}", player.name)).await?;
+ Ok(())
}
#[poise::command(
diff --git a/src/webhook.rs b/src/webhook.rs
index c41f931..76127ad 100644
--- a/src/webhook.rs
+++ b/src/webhook.rs
@@ -151,6 +151,14 @@ fn get(line: &str) -> Option<Message> {
Message::Join { player }
});
}
+ static KICKAGE: LazyLock<Regex> = LazyLock::new(|| {
+ Regex::new(r"Kicking connection [0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3} \/ [^;]+; Reason: (.+)")
+ .unwrap()
+ });
+ if KICKAGE.is_match(line) {
+ return None;
+ }
+
static MAP_LOAD: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"Loading map (.+)").unwrap());
if let Some(captures) = MAP_LOAD.captures(line) {
return Some(Message::Load {