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 {
|
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;
|
return false;
|
||||||
}
|
};
|
||||||
|
let without_prefix = without_prefix.trim();
|
||||||
let without_prefix = content.trim_start_matches(prefix).trim();
|
|
||||||
without_prefix
|
without_prefix
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.next()
|
.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> {
|
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| {
|
all_command_metadata().into_iter().find_map(|meta| {
|
||||||
if meta
|
if meta
|
||||||
.default_aliases
|
.default_aliases
|
||||||
|
|||||||
@@ -110,11 +110,10 @@ pub async fn handle_message(ctx: &Context, msg: &Message) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !content.starts_with(&prefix_value) {
|
let Some(without_prefix) = content.strip_prefix(&prefix_value) else {
|
||||||
return;
|
return;
|
||||||
}
|
};
|
||||||
|
let without_prefix = without_prefix.trim();
|
||||||
let without_prefix = content.trim_start_matches(&prefix_value).trim();
|
|
||||||
if without_prefix.is_empty() {
|
if without_prefix.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user