Skip to content

Update URL #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -123,7 +125,18 @@ impl Handler {
})
.unwrap()
}

/// Removes all greps from a user.
fn purge_greps(content: &str, greps: &mut HashSet<Grep>, 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<Grep>, author: &User) -> String {
Expand Down
2 changes: 1 addition & 1 deletion src/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
2 changes: 1 addition & 1 deletion src/syntax.md
Original file line number Diff line number Diff line change
@@ -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/)