channels: guard messageActions runtime
This commit is contained in:
parent
ad6825c5e0
commit
1f2013299c
@ -31,12 +31,22 @@ import { getDiscordRuntime } from "./runtime.js";
|
||||
|
||||
const meta = getChatChannelMeta("discord");
|
||||
|
||||
function resolveDiscordMessageActions() {
|
||||
try {
|
||||
return getDiscordRuntime().channel.discord?.messageActions ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const discordMessageActions: ChannelMessageActionAdapter = {
|
||||
listActions: (ctx) => getDiscordRuntime().channel.discord.messageActions.listActions(ctx),
|
||||
extractToolSend: (ctx) =>
|
||||
getDiscordRuntime().channel.discord.messageActions.extractToolSend(ctx),
|
||||
handleAction: async (ctx) =>
|
||||
await getDiscordRuntime().channel.discord.messageActions.handleAction(ctx),
|
||||
listActions: (ctx) => resolveDiscordMessageActions()?.listActions?.(ctx) ?? [],
|
||||
extractToolSend: (ctx) => resolveDiscordMessageActions()?.extractToolSend?.(ctx),
|
||||
handleAction: async (ctx) => {
|
||||
const actions = resolveDiscordMessageActions();
|
||||
if (!actions?.handleAction) return null;
|
||||
return await actions.handleAction(ctx);
|
||||
},
|
||||
};
|
||||
|
||||
export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount> = {
|
||||
|
||||
@ -25,11 +25,22 @@ import {
|
||||
|
||||
import { getSignalRuntime } from "./runtime.js";
|
||||
|
||||
function resolveSignalMessageActions() {
|
||||
try {
|
||||
return getSignalRuntime().channel.signal?.messageActions ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const signalMessageActions: ChannelMessageActionAdapter = {
|
||||
listActions: (ctx) => getSignalRuntime().channel.signal.messageActions.listActions(ctx),
|
||||
supportsAction: (ctx) => getSignalRuntime().channel.signal.messageActions.supportsAction?.(ctx),
|
||||
handleAction: async (ctx) =>
|
||||
await getSignalRuntime().channel.signal.messageActions.handleAction(ctx),
|
||||
listActions: (ctx) => resolveSignalMessageActions()?.listActions?.(ctx) ?? [],
|
||||
supportsAction: (ctx) => resolveSignalMessageActions()?.supportsAction?.(ctx),
|
||||
handleAction: async (ctx) => {
|
||||
const actions = resolveSignalMessageActions();
|
||||
if (!actions?.handleAction) return null;
|
||||
return await actions.handleAction(ctx);
|
||||
},
|
||||
};
|
||||
|
||||
const meta = getChatChannelMeta("signal");
|
||||
|
||||
@ -31,12 +31,22 @@ import { getTelegramRuntime } from "./runtime.js";
|
||||
|
||||
const meta = getChatChannelMeta("telegram");
|
||||
|
||||
function resolveTelegramMessageActions() {
|
||||
try {
|
||||
return getTelegramRuntime().channel.telegram?.messageActions ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const telegramMessageActions: ChannelMessageActionAdapter = {
|
||||
listActions: (ctx) => getTelegramRuntime().channel.telegram.messageActions.listActions(ctx),
|
||||
extractToolSend: (ctx) =>
|
||||
getTelegramRuntime().channel.telegram.messageActions.extractToolSend(ctx),
|
||||
handleAction: async (ctx) =>
|
||||
await getTelegramRuntime().channel.telegram.messageActions.handleAction(ctx),
|
||||
listActions: (ctx) => resolveTelegramMessageActions()?.listActions?.(ctx) ?? [],
|
||||
extractToolSend: (ctx) => resolveTelegramMessageActions()?.extractToolSend?.(ctx),
|
||||
handleAction: async (ctx) => {
|
||||
const actions = resolveTelegramMessageActions();
|
||||
if (!actions?.handleAction) return null;
|
||||
return await actions.handleAction(ctx);
|
||||
},
|
||||
};
|
||||
|
||||
function parseReplyToMessageId(replyToId?: string | null) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user