Disallow inviting banned players
This commit is contained in:
parent
c1e15672a8
commit
bc762d4897
22
src/bot.rs
22
src/bot.rs
@ -117,6 +117,10 @@ impl Bot {
|
|||||||
})
|
})
|
||||||
.ok_or_else(|| format!("Failed to find info for uid {sender_uid}"))?;
|
.ok_or_else(|| format!("Failed to find info for uid {sender_uid}"))?;
|
||||||
|
|
||||||
|
if self.ban_list.contains(&sender_info.uuid) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
// Process commands with no arguments
|
// Process commands with no arguments
|
||||||
|
|
||||||
if content == "inv" {
|
if content == "inv" {
|
||||||
@ -259,12 +263,12 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"inv" => {
|
"inv" => {
|
||||||
if !self.ban_list.contains(&sender_info.uuid) {
|
|
||||||
for word in words {
|
for word in words {
|
||||||
info!("Inviting {word}");
|
info!("Inviting {word}");
|
||||||
|
|
||||||
let uid = self.find_uid(word)?;
|
let (uid, uuid) = self.find_ids(word)?;
|
||||||
|
|
||||||
|
if !self.ban_list.contains(&uuid) {
|
||||||
self.client.send_invite(uid, InviteKind::Group);
|
self.client.send_invite(uid, InviteKind::Group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,6 +427,20 @@ impl Bot {
|
|||||||
})
|
})
|
||||||
.ok_or(format!("Failed to find uuid for player {}", name))
|
.ok_or(format!("Failed to find uuid for player {}", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_ids(&self, name: &str) -> Result<(Uid, Uuid), String> {
|
||||||
|
self.client
|
||||||
|
.player_list()
|
||||||
|
.iter()
|
||||||
|
.find_map(|(uid, info)| {
|
||||||
|
if info.player_alias == name {
|
||||||
|
Some((*uid, info.uuid))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ok_or(format!("Failed to find ids for player {}", name))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connect_to_veloren(username: &str, password: &str) -> Result<Client, String> {
|
fn connect_to_veloren(username: &str, password: &str) -> Result<Client, String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user