mirror of
https://github.com/arthur-pbty/shadowbot.git
synced 2026-06-03 15:07:37 +02:00
fix(prefix): prevent multiple prefix usage like ++++ping (#1)
This commit is contained in:
@@ -28,11 +28,10 @@ fn has_only_photo_attachments(msg: &Message) -> bool {
|
||||
}
|
||||
|
||||
fn is_piconly_command_message(content: &str, prefix: &str) -> bool {
|
||||
if !content.starts_with(prefix) {
|
||||
let Some(without_prefix) = content.strip_prefix(prefix) else {
|
||||
return false;
|
||||
}
|
||||
|
||||
let without_prefix = content.trim_start_matches(prefix).trim();
|
||||
};
|
||||
let without_prefix = without_prefix.trim();
|
||||
without_prefix
|
||||
.split_whitespace()
|
||||
.next()
|
||||
|
||||
+1
-1
@@ -662,7 +662,7 @@ pub fn command_metadata_by_key(key: &str) -> Option<CommandMetadata> {
|
||||
}
|
||||
|
||||
pub fn resolve_default_alias(alias: &str) -> Option<&'static str> {
|
||||
let normalized = alias.trim().trim_start_matches('+').to_lowercase();
|
||||
let normalized = alias.trim().to_lowercase();
|
||||
all_command_metadata().into_iter().find_map(|meta| {
|
||||
if meta
|
||||
.default_aliases
|
||||
|
||||
@@ -110,11 +110,10 @@ pub async fn handle_message(ctx: &Context, msg: &Message) {
|
||||
return;
|
||||
}
|
||||
|
||||
if !content.starts_with(&prefix_value) {
|
||||
let Some(without_prefix) = content.strip_prefix(&prefix_value) else {
|
||||
return;
|
||||
}
|
||||
|
||||
let without_prefix = content.trim_start_matches(&prefix_value).trim();
|
||||
};
|
||||
let without_prefix = without_prefix.trim();
|
||||
if without_prefix.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user