@emotion-machine/claw-messenger 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/outbound/send.js +24 -2
- package/package.json +1 -1
package/dist/outbound/send.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as pluginSdk from "openclaw/plugin-sdk";
|
|
2
2
|
function stripLegacyNamespacePrefix(target) {
|
|
3
3
|
let normalized = target.trim();
|
|
4
4
|
while (normalized.startsWith("claw-messenger:") || normalized.startsWith("linq:")) {
|
|
@@ -10,11 +10,33 @@ function stripLegacyNamespacePrefix(target) {
|
|
|
10
10
|
}
|
|
11
11
|
return normalized;
|
|
12
12
|
}
|
|
13
|
+
function fallbackNormalizeE164(input) {
|
|
14
|
+
if (!input)
|
|
15
|
+
return null;
|
|
16
|
+
const stripped = input.trim().replace(/[\s\-().]/g, "");
|
|
17
|
+
if (/^\+\d{10,15}$/.test(stripped))
|
|
18
|
+
return stripped;
|
|
19
|
+
if (/^\d{10,15}$/.test(stripped))
|
|
20
|
+
return `+${stripped}`;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function normalizeE164Compat(input) {
|
|
24
|
+
const sdkNormalize = typeof pluginSdk.normalizeE164 === "function" ? pluginSdk.normalizeE164 : null;
|
|
25
|
+
if (sdkNormalize) {
|
|
26
|
+
try {
|
|
27
|
+
return sdkNormalize(input);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Older OpenClaw builds may not expose a callable normalizeE164 helper yet.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return fallbackNormalizeE164(input);
|
|
34
|
+
}
|
|
13
35
|
export function normalizeDirectTarget(target) {
|
|
14
36
|
const stripped = stripLegacyNamespacePrefix(target);
|
|
15
37
|
if (!stripped)
|
|
16
38
|
return null;
|
|
17
|
-
return
|
|
39
|
+
return normalizeE164Compat(stripped) ?? stripped;
|
|
18
40
|
}
|
|
19
41
|
export async function sendText(ws, to, text, service) {
|
|
20
42
|
return sendMessage(ws, to, [{ type: "text", value: text }], service);
|