Improve is_admin function and the admin docs
This commit is contained in:
parent
5f03f6bac3
commit
677b472d66
@ -24,7 +24,7 @@ Create a "secrets.toml" file:
|
|||||||
username = "bot_username"
|
username = "bot_username"
|
||||||
password = "bot_password"
|
password = "bot_password"
|
||||||
character = "bot_character"
|
character = "bot_character"
|
||||||
admins = ["my_username"]
|
admins = ["my_username"] # You may add usernames or UUIDs to this list. The only advantage of using UUIDs is that it will persist accross changes to your username or player alias.
|
||||||
```
|
```
|
||||||
|
|
||||||
Then create a secret to pass the file securely to the container.
|
Then create a secret to pass the file securely to the container.
|
||||||
|
@ -807,13 +807,18 @@ impl Bot {
|
|||||||
|
|
||||||
/// Determines if the Uid belongs to an admin.
|
/// Determines if the Uid belongs to an admin.
|
||||||
fn is_user_admin(&self, uid: &Uid) -> Result<bool, String> {
|
fn is_user_admin(&self, uid: &Uid) -> Result<bool, String> {
|
||||||
|
let sender_name = self.find_player_alias(uid).ok_or("Failed to find name")?;
|
||||||
|
|
||||||
|
if self.admins.contains(sender_name) {
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
let sender_uuid = self
|
let sender_uuid = self
|
||||||
.find_uuid(uid)
|
.find_uuid(uid)
|
||||||
.ok_or("Failed to find uuid")?
|
.ok_or("Failed to find uuid")?
|
||||||
.to_string();
|
.to_string();
|
||||||
let sender_name = self.find_player_alias(uid).ok_or("Failed to find name")?;
|
|
||||||
|
|
||||||
Ok(self.admins.contains(sender_name) || self.admins.contains(&sender_uuid))
|
Ok(self.admins.contains(&sender_uuid))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves the character to the configured position and orientation.
|
/// Moves the character to the configured position and orientation.
|
||||||
|
Loading…
Reference in New Issue
Block a user