mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:41:25 +00:00
refactor(shared): centralize @/# slug normalization
This commit is contained in:
@@ -9,7 +9,7 @@ import type {
|
||||
GroupToolPolicyBySenderConfig,
|
||||
GroupToolPolicyConfig,
|
||||
} from "../../config/types.tools.js";
|
||||
import { normalizeHyphenSlug } from "../../shared/string-normalization.js";
|
||||
import { normalizeAtHashSlug, normalizeHyphenSlug } from "../../shared/string-normalization.js";
|
||||
import { resolveSlackAccount } from "../../slack/accounts.js";
|
||||
|
||||
type GroupMentionParams = {
|
||||
@@ -25,18 +25,7 @@ type GroupMentionParams = {
|
||||
};
|
||||
|
||||
function normalizeDiscordSlug(value?: string | null) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
let text = value.trim().toLowerCase();
|
||||
if (!text) {
|
||||
return "";
|
||||
}
|
||||
text = text.replace(/^[@#]+/, "");
|
||||
text = text.replace(/[\s_]+/g, "-");
|
||||
text = text.replace(/[^a-z0-9-]+/g, "-");
|
||||
text = text.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
||||
return text;
|
||||
return normalizeAtHashSlug(value);
|
||||
}
|
||||
|
||||
function parseTelegramGroupId(value?: string | null) {
|
||||
|
||||
Reference in New Issue
Block a user