-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code obfuscation bypass and better matches
- Loading branch information
Showing
5 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rust-nitro-sniper" | ||
version = "2.4.1" | ||
version = "2.5.0" | ||
authors = ["Mel"] | ||
edition = "2018" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod config; | ||
mod discord; | ||
mod webhook; | ||
mod matcher; | ||
#[macro_use] | ||
mod logging; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use serenity::model::channel::Message; | ||
use regex::Regex; | ||
|
||
pub fn get_gift_code(message: &Message) -> Option<String> { | ||
lazy_static! { | ||
static ref GIFT_PATTERN: Regex = Regex::new("(discord.com/gifts/|discordapp.com/gifts/|discord.gift/)[ ]*([a-zA-Z0-9]{16,24})").unwrap(); | ||
} | ||
let cleaned_content = sanitize_markdown(&message.content); | ||
if let Some(captures) = GIFT_PATTERN.captures(&cleaned_content) { | ||
Some(captures.get(2).unwrap().as_str().to_string()) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn sanitize_markdown(dirty_string: &str) -> String { | ||
const MARKDOWN_CHARS: [char; 5] = ['*', '_', '`', '~', '|']; | ||
let mut output = dirty_string.to_string(); | ||
output.retain(|c| !MARKDOWN_CHARS.contains(&c)); | ||
output | ||
} |