mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-12 16:40:44 +08:00
Add Telegram and Discord IM channels
This commit is contained in:
parent
7123fce47a
commit
cb74e1c4c7
66 changed files with 8579 additions and 1910 deletions
30
plugin-src/host/channels/telegram/index.mjs
Normal file
30
plugin-src/host/channels/telegram/index.mjs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { createProductionController } from './production.mjs';
|
||||
import { installTelegramRpc } from './rpc.mjs';
|
||||
|
||||
export const name = 'dsh-im-telegram-host';
|
||||
export const inject = ['connection', 'credentials', 'webServer'];
|
||||
|
||||
export async function apply(ctx, config = {}) {
|
||||
if (config?.controller) {
|
||||
return installTelegramRpc(ctx, config.controller, config.rpcAuthority);
|
||||
}
|
||||
const production = await createProductionController(ctx, config, config.internals ?? {});
|
||||
const disposeRpc = installTelegramRpc(ctx, production.controller, config.rpcAuthority);
|
||||
ctx.effect(() => async () => production.close(), 'dsh-im: close Telegram bot connections');
|
||||
return disposeRpc;
|
||||
}
|
||||
|
||||
export function createTelegramHostPlugin(config) {
|
||||
return Object.freeze({ name, inject, apply: (ctx) => apply(ctx, config) });
|
||||
}
|
||||
|
||||
export { createProductionController } from './production.mjs';
|
||||
export {
|
||||
TELEGRAM_ENDPOINTS,
|
||||
TELEGRAM_RPC_CHANNEL,
|
||||
TELEGRAM_RPC_ENDPOINTS,
|
||||
createTelegramRpcHandler,
|
||||
installTelegramRpc,
|
||||
} from './rpc.mjs';
|
||||
export { TelegramController } from '../../../../src/channels/telegram/telegram-controller.mjs';
|
||||
export { TelegramRuntime } from '../../../../src/channels/telegram/telegram-runtime.mjs';
|
||||
Loading…
Add table
Add a link
Reference in a new issue