mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
24 lines
852 B
JavaScript
24 lines
852 B
JavaScript
import {
|
|
TOKEN_BOT_ENDPOINTS,
|
|
createTokenBotRpcHandler,
|
|
} from '../shared/rpc.mjs';
|
|
import { resolveRpcAuthority } from '../../rpc-authority.mjs';
|
|
|
|
export const TELEGRAM_RPC_CHANNEL = '/telegram';
|
|
export const TELEGRAM_ENDPOINTS = TOKEN_BOT_ENDPOINTS;
|
|
export const TELEGRAM_RPC_ENDPOINTS = Object.freeze(Object.values(TELEGRAM_ENDPOINTS));
|
|
|
|
export function createTelegramRpcHandler(controller) {
|
|
return createTokenBotRpcHandler(controller, { channel: 'Telegram' });
|
|
}
|
|
|
|
export function installTelegramRpc(ctx, controller, authority) {
|
|
if (!ctx?.connection?.rpc || typeof ctx.connection.rpc.handle !== 'function') {
|
|
throw new TypeError('DSH Host Connection RPC is required');
|
|
}
|
|
return ctx.connection.rpc.handle(
|
|
TELEGRAM_RPC_CHANNEL,
|
|
createTelegramRpcHandler(controller),
|
|
{ authority: resolveRpcAuthority(authority) },
|
|
);
|
|
}
|