Skip to content

Commit

Permalink
Merge pull request #18 from birlug/hotfix/ignored-commands
Browse files Browse the repository at this point in the history
hotfix: prevent executing special commands manually
  • Loading branch information
amiremohamadi authored Oct 18, 2024
2 parents 3fff8ce + 52bb6c1 commit 54ee8ce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
let mut bot = Bot::new(token, config, kv).expect("could not initialize the bot");

// commands
let ignored_commands = ["report", "join", "easter-egg"];
RESPONSE_DIR.files().for_each(|f| {
let k = f.path().to_str().unwrap(); // safe to unwrap
let r = f.contents_utf8().unwrap(); // safe to unwrap
bot.commands
.insert(format!("!{}", k), Box::new(|b, m| b.reply(m, r)));
if !ignored_commands.contains(&k) {
bot.commands
.insert(format!("!{}", k), Box::new(|b, m| b.reply(m, r)));
}
});
bot.commands
.insert("!report".to_string(), Box::new(commands::report));
Expand Down

0 comments on commit 54ee8ce

Please sign in to comment.