forked from projectmoon/tenebrous-dicebot
Add an is_secure attribute for commands.
This commit is contained in:
parent
5643677627
commit
9de74d05a9
|
@ -12,6 +12,10 @@ impl Command for RollCommand {
|
|||
"roll regular dice"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult {
|
||||
let roll = self.0.roll();
|
||||
let html = format!(
|
||||
|
|
|
@ -11,6 +11,10 @@ impl Command for PoolRollCommand {
|
|||
"roll dice pool"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let pool_with_ctx = DicePoolWithContext(&self.0, ctx);
|
||||
let rolled_pool = roll_pool(&pool_with_ctx).await?;
|
||||
|
|
|
@ -14,6 +14,10 @@ impl Command for CthRoll {
|
|||
"roll percentile dice"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let roll_with_ctx = DiceRollWithContext(&self.0, ctx);
|
||||
let executed_roll = regular_roll(&roll_with_ctx).await?;
|
||||
|
@ -35,6 +39,10 @@ impl Command for CthAdvanceRoll {
|
|||
"roll skill advancement dice"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let roll_with_ctx = AdvancementRollWithContext(&self.0, ctx);
|
||||
let executed_roll = advancement_roll(&roll_with_ctx).await?;
|
||||
|
|
|
@ -12,6 +12,10 @@ impl Command for ResyncCommand {
|
|||
"resync room information"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let our_username: Option<UserId> = ctx.matrix_client.user_id().await;
|
||||
let our_username: &str = our_username.as_ref().map_or("", UserId::as_str);
|
||||
|
|
|
@ -11,6 +11,10 @@ impl Command for HelpCommand {
|
|||
"help information"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult {
|
||||
let help = match &self.0 {
|
||||
Some(topic) => topic.message(),
|
||||
|
|
|
@ -96,6 +96,7 @@ impl ResponseExtractor for ExecutionResult {
|
|||
pub trait Command: Send + Sync {
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult;
|
||||
fn name(&self) -> &'static str;
|
||||
fn is_secure(&self) -> bool;
|
||||
}
|
||||
|
||||
/// Attempt to execute a command, and return the content that should
|
||||
|
|
|
@ -12,6 +12,10 @@ impl Command for GetAllVariablesCommand {
|
|||
"get all variables"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let variables = ctx
|
||||
.db
|
||||
|
@ -43,6 +47,10 @@ impl Command for GetVariableCommand {
|
|||
"retrieve variable value"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let name = &self.0;
|
||||
let result = ctx
|
||||
|
@ -69,6 +77,10 @@ impl Command for SetVariableCommand {
|
|||
"set variable value"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let name = &self.0;
|
||||
let value = self.1;
|
||||
|
@ -91,6 +103,10 @@ impl Command for DeleteVariableCommand {
|
|||
"delete variable"
|
||||
}
|
||||
|
||||
fn is_secure(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
||||
let name = &self.0;
|
||||
let result = ctx
|
||||
|
|
Loading…
Reference in New Issue