-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
60 lines (52 loc) · 1.54 KB
/
index.ts
File metadata and controls
60 lines (52 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
import { stripMarkdown } from "./strip.js";
type MarkdownStripConfig = {
channels?: string[];
};
const DEFAULT_CHANNELS = ["imessage"];
const plugin = {
id: "markdown-strip",
name: "Markdown Strip",
description:
"Strips Markdown formatting from outgoing messages on plaintext channels",
configSchema: {
jsonSchema: {
type: "object",
additionalProperties: false,
properties: {
channels: {
type: "array",
items: { type: "string" },
description:
"Channels to strip Markdown from (default: [\"imessage\"])",
},
},
},
uiHints: {
channels: {
label: "Channels",
help: 'Channel IDs to strip Markdown from, e.g. ["imessage", "signal"]',
placeholder: '["imessage"]',
},
},
},
register(api: OpenClawPluginApi) {
const cfg = (api.pluginConfig ?? {}) as MarkdownStripConfig;
const channels = new Set(cfg.channels ?? DEFAULT_CHANNELS);
api.logger.info(
`markdown-strip: active on channels: ${[...channels].join(", ")}`,
);
api.on("message_sending", async (event, ctx) => {
if (!channels.has(ctx.channelId)) return;
if (!event.content) return;
const stripped = stripMarkdown(event.content);
if (stripped !== event.content) {
api.logger.debug?.(
`markdown-strip: cleaned message for ${ctx.channelId}`,
);
return { content: stripped };
}
});
},
};
export default plugin;