telegram-user: rebrand plugin to openclaw
This commit is contained in:
parent
a12e96b3d3
commit
c463b13ef7
@ -3,7 +3,7 @@ summary: "Connect a Telegram user account via MTProto (DMs + groups)"
|
||||
---
|
||||
# Telegram User
|
||||
|
||||
Telegram User connects Moltbot to a **personal Telegram account** using MTProto.
|
||||
Telegram User connects OpenClaw to a **personal Telegram account** using MTProto.
|
||||
Use this when you need user-level DMs or want to message from your own account in groups.
|
||||
|
||||
## Requirements
|
||||
@ -16,7 +16,7 @@ Use this when you need user-level DMs or want to message from your own account i
|
||||
If the plugin is not bundled, install it:
|
||||
|
||||
```bash
|
||||
moltbot plugins install @moltbot/telegram-user
|
||||
openclaw plugins install @openclaw/telegram-user
|
||||
```
|
||||
|
||||
## Configure
|
||||
@ -27,25 +27,25 @@ Option A: env vars (default account only)
|
||||
```bash
|
||||
export TELEGRAM_USER_API_ID="123456"
|
||||
export TELEGRAM_USER_API_HASH="your_api_hash"
|
||||
moltbot channels add --channel telegram-user --use-env
|
||||
openclaw channels add --channel telegram-user --use-env
|
||||
```
|
||||
|
||||
Option B: config
|
||||
```bash
|
||||
moltbot channels add --channel telegram-user --api-id 123456 --api-hash your_api_hash
|
||||
openclaw channels add --channel telegram-user --api-id 123456 --api-hash your_api_hash
|
||||
```
|
||||
|
||||
## Login (QR or phone code)
|
||||
|
||||
QR login (default):
|
||||
```bash
|
||||
moltbot channels login --channel telegram-user
|
||||
openclaw channels login --channel telegram-user
|
||||
```
|
||||
|
||||
Phone login:
|
||||
```bash
|
||||
export TELEGRAM_USER_PHONE="+15551234567"
|
||||
moltbot channels login --channel telegram-user
|
||||
openclaw channels login --channel telegram-user
|
||||
```
|
||||
|
||||
Optional env helpers:
|
||||
@ -57,7 +57,7 @@ Optional env helpers:
|
||||
By default, DMs are protected with pairing. Approve requests with:
|
||||
|
||||
```bash
|
||||
moltbot pairing approve telegram-user <code>
|
||||
openclaw pairing approve telegram-user <code>
|
||||
```
|
||||
|
||||
See [Pairing](/start/pairing) for details.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { MoltbotPluginApi } from "clawdbot/plugin-sdk";
|
||||
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
||||
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
||||
|
||||
import { telegramUserPlugin } from "./src/channel.js";
|
||||
import { setTelegramUserRuntime } from "./src/runtime.js";
|
||||
@ -9,7 +9,7 @@ const plugin = {
|
||||
name: "Telegram User",
|
||||
description: "Telegram MTProto user channel plugin",
|
||||
configSchema: emptyPluginConfigSchema(),
|
||||
register(api: MoltbotPluginApi) {
|
||||
register(api: OpenClawPluginApi) {
|
||||
setTelegramUserRuntime(api.runtime);
|
||||
api.registerChannel({ plugin: telegramUserPlugin });
|
||||
},
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@moltbot/telegram-user",
|
||||
"version": "2026.1.22",
|
||||
"name": "@openclaw/telegram-user",
|
||||
"version": "2026.1.29",
|
||||
"type": "module",
|
||||
"description": "Moltbot Telegram user (MTProto) channel plugin",
|
||||
"moltbot": {
|
||||
"description": "OpenClaw Telegram user (MTProto) channel plugin",
|
||||
"openclaw": {
|
||||
"extensions": [
|
||||
"./index.ts"
|
||||
],
|
||||
@ -19,7 +19,7 @@
|
||||
"quickstartAllowFrom": true
|
||||
},
|
||||
"install": {
|
||||
"npmSpec": "@moltbot/telegram-user",
|
||||
"npmSpec": "@openclaw/telegram-user",
|
||||
"localPath": "extensions/telegram-user",
|
||||
"defaultChoice": "npm"
|
||||
}
|
||||
@ -33,9 +33,9 @@
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"moltbot": "workspace:*"
|
||||
"openclaw": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"moltbot": ">=2026.1.25"
|
||||
"openclaw": ">=2026.1.29"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { CoreConfig, TelegramUserAccountConfig } from "./types.js";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "clawdbot/plugin-sdk";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk";
|
||||
|
||||
export type TelegramUserCredentials = {
|
||||
apiId?: number;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { TelegramClient } from "@mtcute/node";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "clawdbot/plugin-sdk";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk";
|
||||
|
||||
const activeClients = new Map<string, TelegramClient>();
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { MoltbotConfig, RuntimeEnv } from "clawdbot/plugin-sdk";
|
||||
import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
|
||||
const sendMediaTelegramUser = vi.fn<
|
||||
typeof import("./send.js").sendMediaTelegramUser
|
||||
@ -37,7 +37,7 @@ describe("telegram-user channel plugin", () => {
|
||||
mediaMaxMb: 7,
|
||||
},
|
||||
},
|
||||
} satisfies Partial<MoltbotConfig> as unknown as MoltbotConfig;
|
||||
} satisfies Partial<OpenClawConfig> as unknown as OpenClawConfig;
|
||||
|
||||
const mod = await import("./channel.js");
|
||||
await mod.telegramUserPlugin.outbound?.sendMedia?.({
|
||||
@ -60,7 +60,7 @@ describe("telegram-user channel plugin", () => {
|
||||
channels: {
|
||||
"telegram-user": {},
|
||||
},
|
||||
} satisfies Partial<MoltbotConfig> as unknown as MoltbotConfig;
|
||||
} satisfies Partial<OpenClawConfig> as unknown as OpenClawConfig;
|
||||
|
||||
const mod = await import("./channel.js");
|
||||
await mod.telegramUserPlugin.outbound?.sendMedia?.({
|
||||
@ -88,7 +88,7 @@ describe("telegram-user channel plugin", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies Partial<MoltbotConfig> as unknown as MoltbotConfig;
|
||||
} satisfies Partial<OpenClawConfig> as unknown as OpenClawConfig;
|
||||
|
||||
const mod = await import("./channel.js");
|
||||
const runtime = {
|
||||
|
||||
@ -13,9 +13,9 @@ import {
|
||||
type ChannelGroupContext,
|
||||
type ChannelPlugin,
|
||||
type ChannelSetupInput,
|
||||
type MoltbotConfig,
|
||||
type OpenClawConfig,
|
||||
type GroupToolPolicyConfig,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
|
||||
import {
|
||||
listTelegramUserAccountIds,
|
||||
@ -338,7 +338,7 @@ export const telegramUserPlugin: ChannelPlugin<ResolvedTelegramUserAccount> = {
|
||||
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
||||
applyAccountName: ({ cfg, accountId, name }) =>
|
||||
applyAccountNameToChannelSection({
|
||||
cfg: cfg as MoltbotConfig,
|
||||
cfg: cfg as OpenClawConfig,
|
||||
channelKey: "telegram-user",
|
||||
accountId,
|
||||
name,
|
||||
@ -356,7 +356,7 @@ export const telegramUserPlugin: ChannelPlugin<ResolvedTelegramUserAccount> = {
|
||||
applyAccountConfig: ({ cfg, accountId, input }) => {
|
||||
const setupInput = input as TelegramUserSetupInput;
|
||||
const namedConfig = applyAccountNameToChannelSection({
|
||||
cfg: cfg as MoltbotConfig,
|
||||
cfg: cfg as OpenClawConfig,
|
||||
channelKey: "telegram-user",
|
||||
accountId,
|
||||
name: setupInput.name,
|
||||
@ -454,7 +454,7 @@ export const telegramUserPlugin: ChannelPlugin<ResolvedTelegramUserAccount> = {
|
||||
}
|
||||
}
|
||||
|
||||
const nextCfg = { ...cfg } as MoltbotConfig;
|
||||
const nextCfg = { ...cfg } as OpenClawConfig;
|
||||
const nextSection = cfg.channels?.["telegram-user"]
|
||||
? { ...cfg.channels["telegram-user"] }
|
||||
: undefined;
|
||||
|
||||
@ -17,10 +17,10 @@ export async function createTelegramUserClient(params: {
|
||||
// the "import" condition (ESM), eliminating the warning.
|
||||
const { BaseTelegramClient, TelegramClient, NodePlatform } = await loadMtcuteNode();
|
||||
|
||||
class MoltbotTelegramUserPlatform extends NodePlatform {
|
||||
class OpenClawTelegramUserPlatform extends NodePlatform {
|
||||
// mtcute's default NodePlatform.beforeExit installs SIGINT/SIGTERM handlers that re-send the
|
||||
// signal, which can race with Moltbot's graceful shutdown and close sqlite while writes are
|
||||
// pending. We only hook into process exit events (no signal handlers) and rely on Moltbot to
|
||||
// signal, which can race with OpenClaw's graceful shutdown and close sqlite while writes are
|
||||
// pending. We only hook into process exit events (no signal handlers) and rely on OpenClaw to
|
||||
// stop cleanly.
|
||||
override beforeExit(fn: () => void): () => void {
|
||||
const onBeforeExit = () => fn();
|
||||
@ -38,7 +38,7 @@ export async function createTelegramUserClient(params: {
|
||||
apiId: params.apiId,
|
||||
apiHash: params.apiHash,
|
||||
storage: params.storagePath,
|
||||
platform: new MoltbotTelegramUserPlatform(),
|
||||
platform: new OpenClawTelegramUserPlatform(),
|
||||
});
|
||||
return new TelegramClient({ client });
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
GroupPolicySchema,
|
||||
ToolPolicySchema,
|
||||
requireOpenAllowFrom,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
|
||||
const allowFromEntry = z.union([z.string(), z.number()]);
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import type { ChannelDirectoryEntry, MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { ChannelDirectoryEntry, OpenClawConfig } from "openclaw/plugin-sdk";
|
||||
|
||||
import { resolveTelegramUserAccount } from "./accounts.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
|
||||
export type TelegramUserDirectoryConfigParams = {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
query?: string | null;
|
||||
limit?: number | null;
|
||||
|
||||
@ -2,7 +2,7 @@ import qrcode from "qrcode-terminal";
|
||||
import { createInterface } from "node:readline/promises";
|
||||
import { stdin as input, stdout as output } from "node:process";
|
||||
import { isCancel, select } from "@clack/prompts";
|
||||
import type { RuntimeEnv } from "clawdbot/plugin-sdk";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
|
||||
import { createTelegramUserClient } from "./client.js";
|
||||
import { ensureTelegramUserSessionDir } from "./session.js";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { TelegramClient } from "@mtcute/node";
|
||||
import type { MessageContext } from "@mtcute/dispatcher";
|
||||
import type { RuntimeEnv } from "clawdbot/plugin-sdk";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
|
||||
import {
|
||||
formatLocationText,
|
||||
@ -8,7 +8,7 @@ import {
|
||||
resolveMentionGatingWithBypass,
|
||||
toLocationContext,
|
||||
type NormalizedLocation,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
import { getTelegramUserRuntime } from "../runtime.js";
|
||||
import type { CoreConfig, TelegramUserAccountConfig } from "../types.js";
|
||||
import { sendMediaTelegramUser, sendMessageTelegramUser } from "../send.js";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import fs from "node:fs";
|
||||
import type { RuntimeEnv } from "clawdbot/plugin-sdk";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
|
||||
import { createTelegramUserClient } from "../client.js";
|
||||
import { resolveTelegramUserAccount } from "../accounts.js";
|
||||
@ -60,7 +60,7 @@ export async function monitorTelegramUserProvider(opts: MonitorTelegramUserOpts
|
||||
const storagePath = resolveTelegramUserSessionPath(account.accountId);
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
throw new Error(
|
||||
"Telegram user session missing. Run `moltbot channels login --channel telegram-user` first.",
|
||||
"Telegram user session missing. Run `openclaw channels login --channel telegram-user` first.",
|
||||
);
|
||||
}
|
||||
const client = await createTelegramUserClient({ apiId, apiHash, storagePath });
|
||||
|
||||
@ -6,10 +6,10 @@ import {
|
||||
normalizeAccountId,
|
||||
type ChannelOnboardingAdapter,
|
||||
type ChannelOnboardingDmPolicy,
|
||||
type MoltbotConfig,
|
||||
type OpenClawConfig,
|
||||
type DmPolicy,
|
||||
type WizardPrompter,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
|
||||
import {
|
||||
listTelegramUserAccountIds,
|
||||
@ -24,10 +24,10 @@ const channel = "telegram-user" as const;
|
||||
type TelegramUserChannelConfig = NonNullable<CoreConfig["channels"]>["telegram-user"];
|
||||
|
||||
function setTelegramUserDmPolicy(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
policy: DmPolicy,
|
||||
accountId?: string,
|
||||
): MoltbotConfig {
|
||||
): OpenClawConfig {
|
||||
const resolvedAccountId = normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID;
|
||||
const current = cfg.channels?.["telegram-user"] as TelegramUserChannelConfig | undefined;
|
||||
const allowFrom =
|
||||
@ -73,7 +73,7 @@ async function noteTelegramUserAuthHelp(prompter: WizardPrompter): Promise<void>
|
||||
[
|
||||
"Telegram User (MTProto) needs an API ID + API hash from my.telegram.org.",
|
||||
"You can store them in config or set TELEGRAM_USER_API_ID/TELEGRAM_USER_API_HASH.",
|
||||
"Login happens via `moltbot channels login --channel telegram-user`.",
|
||||
"Login happens via `openclaw channels login --channel telegram-user`.",
|
||||
`Docs: ${formatDocsLink("/channels/telegram-user", "channels/telegram-user")}`,
|
||||
].join("\n"),
|
||||
"Telegram user setup",
|
||||
@ -94,10 +94,10 @@ function parseAllowFromInput(raw: string): string[] {
|
||||
}
|
||||
|
||||
async function promptTelegramUserAllowFrom(params: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
prompter: WizardPrompter;
|
||||
accountId?: string;
|
||||
}): Promise<MoltbotConfig> {
|
||||
}): Promise<OpenClawConfig> {
|
||||
const accountId = normalizeAccountId(params.accountId) ?? DEFAULT_ACCOUNT_ID;
|
||||
const resolved = resolveTelegramUserAccount({
|
||||
cfg: params.cfg as CoreConfig,
|
||||
@ -197,7 +197,7 @@ export const telegramUserOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
let accountId = override ? normalizeAccountId(override) : defaultAccountId;
|
||||
if (shouldPromptAccountIds && !override) {
|
||||
accountId = await promptAccountId({
|
||||
cfg: cfg as MoltbotConfig,
|
||||
cfg: cfg as OpenClawConfig,
|
||||
prompter,
|
||||
label: "Telegram User",
|
||||
currentId: accountId ?? defaultAccountId,
|
||||
@ -344,7 +344,7 @@ export const telegramUserOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
} catch (err) {
|
||||
runtime.error(`Telegram user login failed: ${String(err)}`);
|
||||
await prompter.note(
|
||||
`Run \`moltbot channels login --channel telegram-user\` later to link.`,
|
||||
`Run \`openclaw channels login --channel telegram-user\` later to link.`,
|
||||
"Telegram user login",
|
||||
);
|
||||
}
|
||||
@ -353,7 +353,7 @@ export const telegramUserOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
await prompter.note(
|
||||
[
|
||||
"Next: link the account via QR or phone code.",
|
||||
"Run: moltbot channels login --channel telegram-user",
|
||||
"Run: openclaw channels login --channel telegram-user",
|
||||
].join("\n"),
|
||||
"Telegram user login",
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { PluginRuntime } from "clawdbot/plugin-sdk";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk";
|
||||
|
||||
let runtime: PluginRuntime | null = null;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import type { TelegramClient } from "@mtcute/node";
|
||||
import type { PollInput } from "clawdbot/plugin-sdk";
|
||||
import type { PollInput } from "openclaw/plugin-sdk";
|
||||
|
||||
import { getTelegramUserRuntime } from "./runtime.js";
|
||||
import { resolveTelegramUserAccount } from "./accounts.js";
|
||||
@ -156,7 +156,7 @@ async function resolveClient(params: {
|
||||
const storagePath = resolveTelegramUserSessionPath(account.accountId);
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
throw new Error(
|
||||
"Telegram user session missing. Run `moltbot channels login --channel telegram-user` first.",
|
||||
"Telegram user session missing. Run `openclaw channels login --channel telegram-user` first.",
|
||||
);
|
||||
}
|
||||
const client = await createTelegramUserClient({ apiId, apiHash, storagePath });
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { normalizeAccountId } from "clawdbot/plugin-sdk";
|
||||
import { normalizeAccountId } from "openclaw/plugin-sdk";
|
||||
import { getTelegramUserRuntime } from "./runtime.js";
|
||||
|
||||
export function resolveTelegramUserSessionPath(accountId?: string | null): string {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { DmPolicy, GroupPolicy, GroupToolPolicyConfig } from "clawdbot/plugin-sdk";
|
||||
import type { DmPolicy, GroupPolicy, GroupToolPolicyConfig } from "openclaw/plugin-sdk";
|
||||
|
||||
export type TelegramUserTopicConfig = {
|
||||
requireMention?: boolean;
|
||||
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@ -436,7 +436,7 @@ importers:
|
||||
specifier: ^4.3.6
|
||||
version: 4.3.6
|
||||
devDependencies:
|
||||
clawdbot:
|
||||
openclaw:
|
||||
specifier: workspace:*
|
||||
version: link:../..
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user