diff --git a/src/handler.rs b/src/handler.rs index ad020b4..8e6c7a4 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -71,6 +71,8 @@ impl Handler { "https://github.com/TumblrCommunity/grepbot".into() } else if content == "author" { "talk to artemis (https://github.com/ashfordneil)".into() + } else if content == "purge"{ + Self::purge_greps(content,greps,author) } else { include_str!("usage.md").into() } @@ -123,7 +125,18 @@ impl Handler { }) .unwrap() } - + /// Removes all greps from a user. + fn purge_greps(content: &str, greps: &mut HashSet, author: +&User)->String{ + ///probably very inefficient + ///should be able to just remove all greps at once + ///this is mostly to test the idea + for x in greps.iter(){ + let y="remove "; + y.push_str(x); + remove_grep(y,greps,author); + } + } /// Removes a grep from a user. Accepts a message that beings with "remove ", and then removes the /// grep associated with the user whos regular expression is equal to the remainder of the message. fn remove_grep(content: &str, greps: &mut HashSet, author: &User) -> String { diff --git a/src/help.md b/src/help.md index f321979..8ac2d86 100644 --- a/src/help.md +++ b/src/help.md @@ -2,4 +2,4 @@ I am the new grepbot. You can tell me what you're interested in, and I'll let you know if people start talking about it. All I am is a regex evaluation bot, though. Don't expect anything super clever. **What is Regex?** -Regex (or regular expressions, formally) are a way to write out regular grammars. For those who are interested, you could find a little more info on regular grammars and the theory behind regular expressions here (https://www.tutorialspoint.com/automata_theory/regular_expressions.htm). And for those of you who've used regex before, you'd know that every regex engine has its own syntax. This bot uses the rust regex library, which has its syntax documented here (https://doc.rust-lang.org/regex/regex/index.html). +Regex (or regular expressions, formally) are a way to write out regular grammars. For those who are interested, you could find a little more info on regular grammars and the theory behind regular expressions here (https://www.tutorialspoint.com/automata_theory/regular_expressions.htm). And for those of you who've used regex before, you'd know that every regex engine has its own syntax. This bot uses the rust regex library, which has its syntax documented here (https://docs.rs/regex/0.2.10/regex/) diff --git a/src/syntax.md b/src/syntax.md index 6e9b611..222cc43 100644 --- a/src/syntax.md +++ b/src/syntax.md @@ -1,2 +1,2 @@ **What is Regex?** -Regex (or regular expressions, formally) are a way to write out regular grammars. For those who are interested, you could find a little more info on regular grammars and the theory behind regular expressions here (https://www.tutorialspoint.com/automata_theory/regular_expressions.htm). And for those of you who've used regex before, you'd know that every regex engine has its own syntax. This bot uses the rust regex library, which has its syntax documented here (https://doc.rust-lang.org/regex/regex/index.html). +Regex (or regular expressions, formally) are a way to write out regular grammars. For those who are interested, you could find a little more info on regular grammars and the theory behind regular expressions here (https://www.tutorialspoint.com/automata_theory/regular_expressions.htm). And for those of you who've used regex before, you'd know that every regex engine has its own syntax. This bot uses the rust regex library, which has its syntax documented here (https://docs.rs/regex/0.2.10/regex/)