mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 13:41:30 +00:00
refactor(channels): route core through registered plugin capabilities
This commit is contained in:
@@ -1,9 +1,28 @@
|
||||
import { sendMessageIMessage as sendMessageIMessageImpl } from "../../plugin-sdk/imessage.js";
|
||||
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
|
||||
type RuntimeSend = {
|
||||
sendMessage: typeof import("../../plugin-sdk/imessage.js").sendMessageIMessage;
|
||||
type IMessageRuntimeSendOpts = {
|
||||
config?: ReturnType<typeof loadConfig>;
|
||||
mediaUrl?: string;
|
||||
mediaLocalRoots?: readonly string[];
|
||||
accountId?: string;
|
||||
replyToId?: string;
|
||||
};
|
||||
|
||||
export const runtimeSend = {
|
||||
sendMessage: sendMessageIMessageImpl,
|
||||
} satisfies RuntimeSend;
|
||||
sendMessage: async (to: string, text: string, opts: IMessageRuntimeSendOpts = {}) => {
|
||||
const outbound = await loadChannelOutboundAdapter("imessage");
|
||||
if (!outbound?.sendText) {
|
||||
throw new Error("iMessage outbound adapter is unavailable.");
|
||||
}
|
||||
return await outbound.sendText({
|
||||
cfg: opts.config ?? loadConfig(),
|
||||
to,
|
||||
text,
|
||||
mediaUrl: opts.mediaUrl,
|
||||
mediaLocalRoots: opts.mediaLocalRoots,
|
||||
accountId: opts.accountId,
|
||||
replyToId: opts.replyToId,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,39 @@
|
||||
import { sendMessageTelegram as sendMessageTelegramImpl } from "../../plugin-sdk/telegram-runtime.js";
|
||||
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
|
||||
type RuntimeSend = {
|
||||
sendMessage: typeof import("../../plugin-sdk/telegram-runtime.js").sendMessageTelegram;
|
||||
type TelegramRuntimeSendOpts = {
|
||||
cfg?: ReturnType<typeof loadConfig>;
|
||||
mediaUrl?: string;
|
||||
mediaLocalRoots?: readonly string[];
|
||||
accountId?: string;
|
||||
messageThreadId?: string | number;
|
||||
replyToMessageId?: string | number;
|
||||
silent?: boolean;
|
||||
forceDocument?: boolean;
|
||||
gatewayClientScopes?: readonly string[];
|
||||
};
|
||||
|
||||
export const runtimeSend = {
|
||||
sendMessage: sendMessageTelegramImpl,
|
||||
} satisfies RuntimeSend;
|
||||
sendMessage: async (to: string, text: string, opts: TelegramRuntimeSendOpts = {}) => {
|
||||
const outbound = await loadChannelOutboundAdapter("telegram");
|
||||
if (!outbound?.sendText) {
|
||||
throw new Error("Telegram outbound adapter is unavailable.");
|
||||
}
|
||||
return await outbound.sendText({
|
||||
cfg: opts.cfg ?? loadConfig(),
|
||||
to,
|
||||
text,
|
||||
mediaUrl: opts.mediaUrl,
|
||||
mediaLocalRoots: opts.mediaLocalRoots,
|
||||
accountId: opts.accountId,
|
||||
threadId: opts.messageThreadId,
|
||||
replyToId:
|
||||
opts.replyToMessageId == null
|
||||
? undefined
|
||||
: String(opts.replyToMessageId).trim() || undefined,
|
||||
silent: opts.silent,
|
||||
forceDocument: opts.forceDocument,
|
||||
gatewayClientScopes: opts.gatewayClientScopes,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user