agent-messenger 2.11.2 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/README.md +11 -1
- package/.claude-plugin/marketplace.json +14 -1
- package/.claude-plugin/plugin.json +4 -2
- package/CONTRIBUTING.md +12 -0
- package/README.md +41 -4
- package/dist/package.json +10 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +3 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/channeltalk/credential-manager.js +2 -2
- package/dist/src/platforms/channeltalk/credential-manager.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/credential-manager.js +2 -2
- package/dist/src/platforms/channeltalkbot/credential-manager.js.map +1 -1
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/discord/credential-manager.js +2 -2
- package/dist/src/platforms/discord/credential-manager.js.map +1 -1
- package/dist/src/platforms/discordbot/credential-manager.js +2 -2
- package/dist/src/platforms/discordbot/credential-manager.js.map +1 -1
- package/dist/src/platforms/instagram/credential-manager.js +2 -2
- package/dist/src/platforms/instagram/credential-manager.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +3 -4
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/credential-manager.js +2 -2
- package/dist/src/platforms/kakaotalk/credential-manager.js.map +1 -1
- package/dist/src/platforms/line/client.js +2 -2
- package/dist/src/platforms/line/client.js.map +1 -1
- package/dist/src/platforms/line/credential-manager.js +2 -2
- package/dist/src/platforms/line/credential-manager.js.map +1 -1
- package/dist/src/platforms/slack/credential-manager.js +2 -2
- package/dist/src/platforms/slack/credential-manager.js.map +1 -1
- package/dist/src/platforms/slackbot/credential-manager.js +2 -2
- package/dist/src/platforms/slackbot/credential-manager.js.map +1 -1
- package/dist/src/platforms/teams/credential-manager.js +2 -2
- package/dist/src/platforms/teams/credential-manager.js.map +1 -1
- package/dist/src/platforms/telegram/credential-manager.js +2 -2
- package/dist/src/platforms/telegram/credential-manager.js.map +1 -1
- package/dist/src/platforms/telegrambot/cli.d.ts +5 -0
- package/dist/src/platforms/telegrambot/cli.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/cli.js +29 -0
- package/dist/src/platforms/telegrambot/cli.js.map +1 -0
- package/dist/src/platforms/telegrambot/client.d.ts +85 -0
- package/dist/src/platforms/telegrambot/client.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/client.js +282 -0
- package/dist/src/platforms/telegrambot/client.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/auth.d.ts +31 -0
- package/dist/src/platforms/telegrambot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/auth.js +173 -0
- package/dist/src/platforms/telegrambot/commands/auth.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/chat.d.ts +25 -0
- package/dist/src/platforms/telegrambot/commands/chat.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/chat.js +69 -0
- package/dist/src/platforms/telegrambot/commands/chat.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/index.d.ts +6 -0
- package/dist/src/platforms/telegrambot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/index.js +6 -0
- package/dist/src/platforms/telegrambot/commands/index.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/message.d.ts +39 -0
- package/dist/src/platforms/telegrambot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/message.js +145 -0
- package/dist/src/platforms/telegrambot/commands/message.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/reaction.d.ts +16 -0
- package/dist/src/platforms/telegrambot/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/reaction.js +49 -0
- package/dist/src/platforms/telegrambot/commands/reaction.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/shared.d.ts +12 -0
- package/dist/src/platforms/telegrambot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/shared.js +21 -0
- package/dist/src/platforms/telegrambot/commands/shared.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/whoami.d.ts +17 -0
- package/dist/src/platforms/telegrambot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/whoami.js +30 -0
- package/dist/src/platforms/telegrambot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/telegrambot/credential-manager.d.ts +17 -0
- package/dist/src/platforms/telegrambot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/credential-manager.js +113 -0
- package/dist/src/platforms/telegrambot/credential-manager.js.map +1 -0
- package/dist/src/platforms/telegrambot/index.d.ts +7 -0
- package/dist/src/platforms/telegrambot/index.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/index.js +5 -0
- package/dist/src/platforms/telegrambot/index.js.map +1 -0
- package/dist/src/platforms/telegrambot/listener.d.ts +30 -0
- package/dist/src/platforms/telegrambot/listener.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/listener.js +186 -0
- package/dist/src/platforms/telegrambot/listener.js.map +1 -0
- package/dist/src/platforms/telegrambot/types.d.ts +256 -0
- package/dist/src/platforms/telegrambot/types.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/types.js +96 -0
- package/dist/src/platforms/telegrambot/types.js.map +1 -0
- package/dist/src/platforms/webex/credential-manager.js +2 -2
- package/dist/src/platforms/webex/credential-manager.js.map +1 -1
- package/dist/src/platforms/wechatbot/credential-manager.js +2 -2
- package/dist/src/platforms/wechatbot/credential-manager.js.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js +2 -2
- package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
- package/dist/src/platforms/whatsappbot/credential-manager.js +2 -2
- package/dist/src/platforms/whatsappbot/credential-manager.js.map +1 -1
- package/dist/src/shared/utils/config-dir.d.ts +14 -0
- package/dist/src/shared/utils/config-dir.d.ts.map +1 -0
- package/dist/src/shared/utils/config-dir.js +22 -0
- package/dist/src/shared/utils/config-dir.js.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts.map +1 -1
- package/dist/src/shared/utils/derived-key-cache.js +2 -2
- package/dist/src/shared/utils/derived-key-cache.js.map +1 -1
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/telegrambot.mdx +149 -0
- package/docs/content/docs/index.mdx +10 -9
- package/docs/content/docs/quick-start.mdx +2 -0
- package/docs/content/docs/sdk/meta.json +1 -0
- package/docs/content/docs/sdk/telegrambot.mdx +216 -0
- package/e2e/config.ts +24 -0
- package/e2e/helpers.ts +1 -0
- package/e2e/telegrambot.e2e.test.ts +185 -0
- package/examples/telegrambot-listen.ts +54 -0
- package/package.json +10 -2
- package/scripts/postbuild.ts +1 -0
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +12 -5
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-telegrambot/SKILL.md +357 -0
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/cli.ts +4 -0
- package/src/platforms/channeltalk/credential-manager.ts +2 -2
- package/src/platforms/channeltalkbot/credential-manager.ts +2 -2
- package/src/platforms/discord/credential-manager.ts +3 -2
- package/src/platforms/discordbot/credential-manager.ts +2 -2
- package/src/platforms/instagram/credential-manager.ts +2 -2
- package/src/platforms/kakaotalk/client.ts +3 -5
- package/src/platforms/kakaotalk/credential-manager.ts +2 -2
- package/src/platforms/line/client.ts +2 -2
- package/src/platforms/line/credential-manager.ts +2 -2
- package/src/platforms/slack/credential-manager.ts +2 -2
- package/src/platforms/slackbot/credential-manager.ts +2 -2
- package/src/platforms/teams/credential-manager.ts +2 -2
- package/src/platforms/telegram/commands/whoami.test.ts +1 -0
- package/src/platforms/telegram/credential-manager.ts +2 -2
- package/src/platforms/telegrambot/cli.ts +34 -0
- package/src/platforms/telegrambot/client.test.ts +454 -0
- package/src/platforms/telegrambot/client.ts +404 -0
- package/src/platforms/telegrambot/commands/auth.test.ts +244 -0
- package/src/platforms/telegrambot/commands/auth.ts +220 -0
- package/src/platforms/telegrambot/commands/chat.ts +96 -0
- package/src/platforms/telegrambot/commands/index.ts +5 -0
- package/src/platforms/telegrambot/commands/message.ts +235 -0
- package/src/platforms/telegrambot/commands/reaction.ts +70 -0
- package/src/platforms/telegrambot/commands/shared.ts +32 -0
- package/src/platforms/telegrambot/commands/whoami.ts +45 -0
- package/src/platforms/telegrambot/credential-manager.test.ts +196 -0
- package/src/platforms/telegrambot/credential-manager.ts +141 -0
- package/src/platforms/telegrambot/index.ts +44 -0
- package/src/platforms/telegrambot/listener.test.ts +398 -0
- package/src/platforms/telegrambot/listener.ts +198 -0
- package/src/platforms/telegrambot/types.test.ts +128 -0
- package/src/platforms/telegrambot/types.ts +282 -0
- package/src/platforms/webex/credential-manager.ts +2 -2
- package/src/platforms/wechatbot/credential-manager.ts +2 -2
- package/src/platforms/whatsapp/credential-manager.ts +2 -2
- package/src/platforms/whatsappbot/credential-manager.ts +2 -2
- package/src/shared/utils/config-dir.test.ts +41 -0
- package/src/shared/utils/config-dir.ts +23 -0
- package/src/shared/utils/derived-key-cache.ts +3 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
3
|
import { join } from 'node:path';
|
|
4
|
+
import { getConfigDir } from '../../shared/utils/config-dir.js';
|
|
5
5
|
import { createAccountId } from './types.js';
|
|
6
6
|
export class WhatsAppCredentialManager {
|
|
7
7
|
configDir;
|
|
8
8
|
credentialsPath;
|
|
9
9
|
baileysRootDir;
|
|
10
10
|
constructor(configDir) {
|
|
11
|
-
this.configDir = configDir ??
|
|
11
|
+
this.configDir = configDir ?? getConfigDir();
|
|
12
12
|
this.credentialsPath = join(this.configDir, 'whatsapp-credentials.json');
|
|
13
13
|
this.baileysRootDir = join(this.configDir, 'whatsapp');
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/whatsapp/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/whatsapp/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAwE,MAAM,SAAS,CAAA;AAE/G,MAAM,OAAO,yBAAyB;IAC5B,SAAS,CAAQ;IACjB,eAAe,CAAQ;IACvB,cAAc,CAAQ;IAE9B,YAAY,SAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,YAAY,EAAE,CAAA;QAC5C,IAAI,CA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AC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrC,MAAM,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACjD,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;YACpC,MAAM,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,eAAe,CAAC,SAAiB;QAC/B,MAAM,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;QAE3D,OAAO;YACL,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;SACnC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,SAAiB;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QAC7C,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
3
|
import { join } from 'node:path';
|
|
4
|
+
import { getConfigDir } from '../../shared/utils/config-dir.js';
|
|
5
5
|
import { WhatsAppBotConfigSchema } from './types.js';
|
|
6
6
|
export class WhatsAppBotCredentialManager {
|
|
7
7
|
configDir;
|
|
8
8
|
credentialsPath;
|
|
9
9
|
constructor(configDir) {
|
|
10
|
-
this.configDir = configDir ??
|
|
10
|
+
this.configDir = configDir ?? getConfigDir();
|
|
11
11
|
this.credentialsPath = join(this.configDir, 'whatsappbot-credentials.json');
|
|
12
12
|
}
|
|
13
13
|
async load() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/whatsappbot/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/whatsappbot/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEjD,MAAM,OAAO,4BAA4B;IAC/B,SAAS,CAAQ;IACjB,eAAe,CAAQ;IAE/B,YAAY,SAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,YAAY,EAAE,CAAA;QAC5C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;QACxC,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,I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,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CONFIG_DIR_ENV_VAR = "AGENT_MESSENGER_CONFIG_DIR";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the directory used to persist agent-messenger configuration and
|
|
4
|
+
* credentials.
|
|
5
|
+
*
|
|
6
|
+
* Resolution order:
|
|
7
|
+
* 1. `AGENT_MESSENGER_CONFIG_DIR` environment variable (if set and non-empty)
|
|
8
|
+
* 2. Default: `~/.config/agent-messenger`
|
|
9
|
+
*
|
|
10
|
+
* Used by every platform credential manager so that a single env var override
|
|
11
|
+
* relocates all stored credentials, sync state, and derived-key caches.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getConfigDir(): string;
|
|
14
|
+
//# sourceMappingURL=config-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-dir.d.ts","sourceRoot":"","sources":["../../../../src/shared/utils/config-dir.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,+BAA+B,CAAA;AAE9D;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export const CONFIG_DIR_ENV_VAR = 'AGENT_MESSENGER_CONFIG_DIR';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the directory used to persist agent-messenger configuration and
|
|
6
|
+
* credentials.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. `AGENT_MESSENGER_CONFIG_DIR` environment variable (if set and non-empty)
|
|
10
|
+
* 2. Default: `~/.config/agent-messenger`
|
|
11
|
+
*
|
|
12
|
+
* Used by every platform credential manager so that a single env var override
|
|
13
|
+
* relocates all stored credentials, sync state, and derived-key caches.
|
|
14
|
+
*/
|
|
15
|
+
export function getConfigDir() {
|
|
16
|
+
const override = process.env[CONFIG_DIR_ENV_VAR];
|
|
17
|
+
if (override && override.length > 0) {
|
|
18
|
+
return override;
|
|
19
|
+
}
|
|
20
|
+
return join(homedir(), '.config', 'agent-messenger');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=config-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-dir.js","sourceRoot":"","sources":["../../../../src/shared/utils/config-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,kBAAkB,GAAG,4BAA4B,CAAA;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAChD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived-key-cache.d.ts","sourceRoot":"","sources":["../../../../src/shared/utils/derived-key-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"derived-key-cache.d.ts","sourceRoot":"","sources":["../../../../src/shared/utils/derived-key-cache.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,aAAa,CAAA;AAElF;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAQ;gBAEZ,QAAQ,CAAC,EAAE,MAAM;IAI7B,OAAO,CAAC,UAAU;IAIZ,GAAG,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAe/C,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAKhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
3
|
import { join } from 'node:path';
|
|
4
|
+
import { getConfigDir } from './config-dir.js';
|
|
5
5
|
/**
|
|
6
6
|
* Caches derived encryption keys to avoid repeated macOS Keychain prompts.
|
|
7
7
|
*
|
|
@@ -14,7 +14,7 @@ import { join } from 'node:path';
|
|
|
14
14
|
export class DerivedKeyCache {
|
|
15
15
|
cacheDir;
|
|
16
16
|
constructor(cacheDir) {
|
|
17
|
-
this.cacheDir = cacheDir ?? join(
|
|
17
|
+
this.cacheDir = cacheDir ?? join(getConfigDir(), '.derived-keys');
|
|
18
18
|
}
|
|
19
19
|
getKeyPath(platform) {
|
|
20
20
|
return join(this.cacheDir, `${platform}.key`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived-key-cache.js","sourceRoot":"","sources":["../../../../src/shared/utils/derived-key-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"derived-key-cache.js","sourceRoot":"","sources":["../../../../src/shared/utils/derived-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AE,KAAK,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,QAAkB;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QAEzC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,MAAM,EAAE,CAAC,OAAO,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Telegram Bot
|
|
3
|
+
description: Complete reference for the agent-telegrambot CLI.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **Tip**: After `npm install -g agent-messenger`, `agent-telegrambot` is available directly. For one-off execution without a global install you can use `npm exec --package agent-messenger agent-telegrambot ...`, `pnpm dlx --package agent-messenger agent-telegrambot ...`, `yarn dlx agent-messenger agent-telegrambot ...`, or `bunx --package agent-messenger agent-telegrambot ...`.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`agent-telegrambot` wraps Telegram's official [HTTP Bot API](https://core.telegram.org/bots/api). It uses bot tokens issued by [@BotFather](https://t.me/BotFather) and is designed for server-side and CI/CD integrations.
|
|
11
|
+
|
|
12
|
+
For acting as a real user account (not a bot), use [`agent-telegram`](./telegram) instead.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- A bot token from [@BotFather](https://t.me/BotFather)
|
|
17
|
+
- Node.js 18+ or Bun runtime
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Set your bot token (validates against Telegram)
|
|
23
|
+
agent-telegrambot auth set 123456789:ABC-DEF1234...
|
|
24
|
+
|
|
25
|
+
# Verify auth
|
|
26
|
+
agent-telegrambot whoami
|
|
27
|
+
|
|
28
|
+
# Send a message
|
|
29
|
+
agent-telegrambot message send @channelname "Hello"
|
|
30
|
+
|
|
31
|
+
# Get chat info
|
|
32
|
+
agent-telegrambot chat info @channelname
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Authentication
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Set bot token
|
|
39
|
+
agent-telegrambot auth set <token>
|
|
40
|
+
|
|
41
|
+
# Set with custom bot identifier
|
|
42
|
+
agent-telegrambot auth set <token> --bot deploy
|
|
43
|
+
|
|
44
|
+
# Check auth status
|
|
45
|
+
agent-telegrambot auth status
|
|
46
|
+
|
|
47
|
+
# List stored bots
|
|
48
|
+
agent-telegrambot auth list
|
|
49
|
+
|
|
50
|
+
# Switch active bot
|
|
51
|
+
agent-telegrambot auth use <bot-id>
|
|
52
|
+
|
|
53
|
+
# Remove a stored bot
|
|
54
|
+
agent-telegrambot auth remove <bot-id>
|
|
55
|
+
|
|
56
|
+
# Clear all credentials
|
|
57
|
+
agent-telegrambot auth clear
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Credentials are stored in `~/.config/agent-messenger/telegrambot-credentials.json` (0600 permissions).
|
|
61
|
+
|
|
62
|
+
## Commands
|
|
63
|
+
|
|
64
|
+
### Messages
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Send a text message
|
|
68
|
+
agent-telegrambot message send <chat> <text>
|
|
69
|
+
|
|
70
|
+
# Format with Markdown or HTML
|
|
71
|
+
agent-telegrambot message send <chat> "<b>Bold</b>" --parse-mode HTML
|
|
72
|
+
|
|
73
|
+
# Reply to a specific message
|
|
74
|
+
agent-telegrambot message send <chat> "Reply" --reply-to 12345
|
|
75
|
+
|
|
76
|
+
# Send silently
|
|
77
|
+
agent-telegrambot message send <chat> "..." --silent
|
|
78
|
+
|
|
79
|
+
# Forum topic
|
|
80
|
+
agent-telegrambot message send <chat> "..." --thread-id 5
|
|
81
|
+
|
|
82
|
+
# Edit a message
|
|
83
|
+
agent-telegrambot message update <chat> <message-id> <new-text>
|
|
84
|
+
|
|
85
|
+
# Delete a message
|
|
86
|
+
agent-telegrambot message delete <chat> <message-id> --force
|
|
87
|
+
|
|
88
|
+
# Forward a message
|
|
89
|
+
agent-telegrambot message forward <to-chat> <from-chat> <message-id>
|
|
90
|
+
|
|
91
|
+
# Upload a document
|
|
92
|
+
agent-telegrambot message upload <chat> ./file.pdf --caption "Report"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Chats
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Get chat info (title, type, description, member count)
|
|
99
|
+
agent-telegrambot chat info <chat>
|
|
100
|
+
|
|
101
|
+
# Get a specific member's status
|
|
102
|
+
agent-telegrambot chat member <chat> <user-id>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Reactions
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Set a reaction (replaces existing)
|
|
109
|
+
agent-telegrambot reaction set <chat> <message-id> 👍
|
|
110
|
+
|
|
111
|
+
# Big animation
|
|
112
|
+
agent-telegrambot reaction set <chat> <message-id> 👍 --big
|
|
113
|
+
|
|
114
|
+
# Clear reactions
|
|
115
|
+
agent-telegrambot reaction clear <chat> <message-id>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Whoami
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
agent-telegrambot whoami
|
|
122
|
+
agent-telegrambot whoami --bot <bot-id>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Chat IDs
|
|
126
|
+
|
|
127
|
+
The `<chat>` argument accepts:
|
|
128
|
+
|
|
129
|
+
- **Numeric ID**: `123456789` (user), `-1001234567890` (supergroup/channel)
|
|
130
|
+
- **@username**: `@channelname` (public chats only)
|
|
131
|
+
- **Plain username**: `channelname` (auto-prefixed with `@`)
|
|
132
|
+
|
|
133
|
+
## Global Options
|
|
134
|
+
|
|
135
|
+
| Option | Description |
|
|
136
|
+
| ------------ | ------------------------------------- |
|
|
137
|
+
| `--pretty` | Human-readable output instead of JSON |
|
|
138
|
+
| `--bot <id>` | Use a specific bot for this command |
|
|
139
|
+
|
|
140
|
+
## Real-Time Events
|
|
141
|
+
|
|
142
|
+
The CLI does not expose real-time events, but the SDK does — via long-polling. See the [SDK reference](../sdk/telegrambot) for `TelegramBotListener`.
|
|
143
|
+
|
|
144
|
+
## Common Errors
|
|
145
|
+
|
|
146
|
+
- `Unauthorized` — Invalid or revoked token. Generate a new one via @BotFather.
|
|
147
|
+
- `Forbidden` — User hasn't `/start`ed the bot, bot was kicked, or bot lacks permissions.
|
|
148
|
+
- `Bad Request: chat not found` — Wrong chat ID or bot isn't in the chat.
|
|
149
|
+
- `Conflict` — Another polling instance (or webhook) is active for this bot.
|
|
@@ -33,14 +33,14 @@ No app creation. No admin approval. No waiting.
|
|
|
33
33
|
|
|
34
34
|
## Key Features
|
|
35
35
|
|
|
36
|
-
| Feature | Description
|
|
37
|
-
| ------------------- |
|
|
38
|
-
| **Auto-extraction** | Pulls tokens from desktop apps automatically
|
|
39
|
-
| **Multi-platform** | Slack, Discord, Microsoft Teams, Telegram, WhatsApp, LINE, Instagram, KakaoTalk, and Channel Talk (beta)
|
|
40
|
-
| **Multi-workspace** | Switch between workspaces/servers easily
|
|
41
|
-
| **JSON output** | Machine-readable by default, `--pretty` for humans
|
|
42
|
-
| **Comprehensive** | Messages, channels, users, reactions, files
|
|
43
|
-
| **Bot support** | [`agent-slackbot`](/docs/cli/slackbot), [`agent-discordbot`](/docs/cli/discordbot), and [`agent-channeltalkbot`](/docs/cli/channeltalkbot) for server-side and CI/CD |
|
|
36
|
+
| Feature | Description |
|
|
37
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
38
|
+
| **Auto-extraction** | Pulls tokens from desktop apps automatically |
|
|
39
|
+
| **Multi-platform** | Slack, Discord, Microsoft Teams, Telegram, WhatsApp, LINE, Instagram, KakaoTalk, and Channel Talk (beta) |
|
|
40
|
+
| **Multi-workspace** | Switch between workspaces/servers easily |
|
|
41
|
+
| **JSON output** | Machine-readable by default, `--pretty` for humans |
|
|
42
|
+
| **Comprehensive** | Messages, channels, users, reactions, files |
|
|
43
|
+
| **Bot support** | [`agent-slackbot`](/docs/cli/slackbot), [`agent-discordbot`](/docs/cli/discordbot), [`agent-telegrambot`](/docs/cli/telegrambot), and [`agent-channeltalkbot`](/docs/cli/channeltalkbot) for server-side and CI/CD |
|
|
44
44
|
|
|
45
45
|
## Why Not MCP?
|
|
46
46
|
|
|
@@ -81,7 +81,7 @@ OAuth is better when you need:
|
|
|
81
81
|
- **Multi-user applications** - Many users authenticating separately
|
|
82
82
|
- **Granular permissions** - Fine-tuned access control
|
|
83
83
|
|
|
84
|
-
For these use cases, Agent Messenger also supports bot tokens via [`agent-slackbot`](/docs/cli/slackbot), [`agent-discordbot`](/docs/cli/discordbot), and [`agent-channeltalkbot`](/docs/cli/channeltalkbot).
|
|
84
|
+
For these use cases, Agent Messenger also supports bot tokens via [`agent-slackbot`](/docs/cli/slackbot), [`agent-discordbot`](/docs/cli/discordbot), [`agent-telegrambot`](/docs/cli/telegrambot), and [`agent-channeltalkbot`](/docs/cli/channeltalkbot).
|
|
85
85
|
|
|
86
86
|
## Design Principles
|
|
87
87
|
|
|
@@ -114,6 +114,7 @@ Tokens stay on your machine. Nothing is sent to external servers. Your credentia
|
|
|
114
114
|
- [Discord Bot](/docs/cli/discordbot) - Bot token integration for server-side and CI/CD
|
|
115
115
|
- [Teams](/docs/cli/teams) - Full Teams command reference
|
|
116
116
|
- [Telegram](/docs/cli/telegram) - TDLib setup and Telegram command reference
|
|
117
|
+
- [Telegram Bot](/docs/cli/telegrambot) - Bot token integration for server-side and CI/CD
|
|
117
118
|
- [WhatsApp](/docs/cli/whatsapp) - Full WhatsApp command reference
|
|
118
119
|
- [WhatsApp Bot](/docs/cli/whatsappbot) - Cloud API integration for WhatsApp Business
|
|
119
120
|
- [LINE](/docs/cli/line) - Full LINE command reference
|
|
@@ -31,6 +31,7 @@ This installs these CLI tools:
|
|
|
31
31
|
- `agent-discordbot` — Discord Bot CLI (bot token, for server-side/CI/CD)
|
|
32
32
|
- `agent-teams` — Microsoft Teams CLI
|
|
33
33
|
- `agent-telegram` — Telegram CLI (user account via TDLib)
|
|
34
|
+
- `agent-telegrambot` — Telegram Bot CLI (bot token, for server-side/CI/CD)
|
|
34
35
|
- `agent-whatsapp` — WhatsApp CLI (user account via Baileys, pairing code auth)
|
|
35
36
|
- `agent-whatsappbot` — WhatsApp Bot CLI (Cloud API, for server-side/CI/CD)
|
|
36
37
|
- `agent-line` — LINE CLI (QR code login, Thrift protocol)
|
|
@@ -123,6 +124,7 @@ agent-slack workspace current
|
|
|
123
124
|
- [Discord Bot Reference](/docs/cli/discordbot) - Bot token for server-side/CI/CD
|
|
124
125
|
- [Teams Reference](/docs/cli/teams) - Full command reference
|
|
125
126
|
- [Telegram Reference](/docs/cli/telegram) - TDLib setup and command reference
|
|
127
|
+
- [Telegram Bot Reference](/docs/cli/telegrambot) - Bot token for server-side/CI/CD
|
|
126
128
|
- [WhatsApp Reference](/docs/cli/whatsapp) - Full command reference
|
|
127
129
|
- [WhatsApp Bot Reference](/docs/cli/whatsappbot) - Cloud API for WhatsApp Business
|
|
128
130
|
- [KakaoTalk Reference](/docs/cli/kakaotalk) - Full command reference
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Telegram Bot
|
|
3
|
+
description: TypeScript SDK reference for Telegram Bot — client, real-time long-polling listener, credential management, and types.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install agent-messenger
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import {
|
|
14
|
+
TelegramBotClient,
|
|
15
|
+
TelegramBotCredentialManager,
|
|
16
|
+
TelegramBotError,
|
|
17
|
+
TelegramBotListener,
|
|
18
|
+
} from 'agent-messenger/telegrambot'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## TelegramBotClient
|
|
22
|
+
|
|
23
|
+
The main client wrapping Telegram's HTTP [Bot API](https://core.telegram.org/bots/api). Includes automatic 429 (rate-limit) handling using `retry_after`, network retries with exponential backoff, and structured errors via `TelegramBotError`.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const client = await new TelegramBotClient().login({ token: 'YOUR_BOT_TOKEN' })
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or use stored credentials — read from `~/.config/agent-messenger/telegrambot-credentials.json` (managed by `agent-telegrambot auth set`):
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const client = await new TelegramBotClient().login()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Authentication
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const me = await client.getMe()
|
|
39
|
+
// → TelegramBotUser { id, is_bot, first_name, username?, ... }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Messages
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Send text message
|
|
46
|
+
const msg = await client.sendMessage(chatId, 'Hello', {
|
|
47
|
+
parse_mode: 'HTML',
|
|
48
|
+
reply_to_message_id: 42,
|
|
49
|
+
disable_notification: true,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Edit a chat message
|
|
53
|
+
await client.editMessageText({ chat_id: chatId, message_id: msg.message_id }, 'Edited text')
|
|
54
|
+
|
|
55
|
+
// Edit an inline-mode message (returned by inline query results)
|
|
56
|
+
await client.editMessageText({ inline_message_id: 'abc123' }, 'Edited text')
|
|
57
|
+
|
|
58
|
+
// Delete
|
|
59
|
+
await client.deleteMessage(chatId, msg.message_id)
|
|
60
|
+
|
|
61
|
+
// Forward
|
|
62
|
+
await client.forwardMessage(toChatId, fromChatId, messageId)
|
|
63
|
+
|
|
64
|
+
// Upload document (multipart)
|
|
65
|
+
await client.sendDocument(chatId, '/path/to/file.pdf', { caption: 'Report' })
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Chats
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Full chat info (title, description, member count, etc.)
|
|
72
|
+
const chat = await client.getChat(chatId)
|
|
73
|
+
|
|
74
|
+
// Single member's status
|
|
75
|
+
const member = await client.getChatMember(chatId, userId)
|
|
76
|
+
|
|
77
|
+
// Member count for groups, supergroups, channels
|
|
78
|
+
const count = await client.getChatMemberCount(chatId)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Reactions
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Set a reaction (Telegram replaces previous bot reaction)
|
|
85
|
+
await client.setMessageReaction(chatId, messageId, [{ type: 'emoji', emoji: '👍' }])
|
|
86
|
+
|
|
87
|
+
// Clear all bot reactions
|
|
88
|
+
await client.setMessageReaction(chatId, messageId, [])
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Updates (Manual Polling)
|
|
92
|
+
|
|
93
|
+
If you don't need the listener abstraction, you can call `getUpdates` directly:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const updates = await client.getUpdates({
|
|
97
|
+
offset: 0,
|
|
98
|
+
limit: 100,
|
|
99
|
+
timeout: 30,
|
|
100
|
+
allowed_updates: ['message', 'callback_query'],
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## TelegramBotListener
|
|
105
|
+
|
|
106
|
+
A long-polling listener for real-time updates. Telegram Bot API does not support WebSockets — long-polling is the canonical streaming mode used by frameworks like grammy and telegraf. No public HTTPS endpoint required.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { TelegramBotClient, TelegramBotListener } from 'agent-messenger/telegrambot'
|
|
110
|
+
|
|
111
|
+
const client = await new TelegramBotClient().login({ token: 'YOUR_BOT_TOKEN' })
|
|
112
|
+
const listener = new TelegramBotListener(client, {
|
|
113
|
+
timeoutSeconds: 30,
|
|
114
|
+
limit: 100,
|
|
115
|
+
allowedUpdates: ['message', 'callback_query'],
|
|
116
|
+
dropPendingUpdates: false,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
listener.on('connected', ({ user }) => {
|
|
120
|
+
console.log(`Connected as @${user.username}`)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
listener.on('message', (message) => {
|
|
124
|
+
console.log(`${message.chat.id}: ${message.text}`)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
listener.on('callback_query', (query) => {
|
|
128
|
+
console.log(`Button clicked: ${query.data}`)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
listener.on('disconnected', () => {
|
|
132
|
+
console.log('Disconnected, will retry…')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
listener.on('error', (error) => {
|
|
136
|
+
console.error('Fatal error:', error)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
await listener.start()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Lifecycle
|
|
143
|
+
|
|
144
|
+
- `start()` — Removes any active webhook (mutex with polling), calls `getMe` to confirm auth, then enters the polling loop.
|
|
145
|
+
- `stop()` — Aborts the in-flight `getUpdates` request and stops the loop. Safe to call multiple times.
|
|
146
|
+
|
|
147
|
+
### Events
|
|
148
|
+
|
|
149
|
+
| Event | Payload | Notes |
|
|
150
|
+
| --------------------- | ----------------------------- | ----------------------------------------------------------------------- |
|
|
151
|
+
| `connected` | `{ user: TelegramBotUser }` | Once after `start()` succeeds |
|
|
152
|
+
| `disconnected` | `[]` | After a recoverable error; listener will retry with exponential backoff |
|
|
153
|
+
| `error` | `[Error]` | Fatal error (Unauthorized 401, Conflict 409). Listener stops. |
|
|
154
|
+
| `message` | `[TelegramMessage]` | New text/media messages in private chats and groups |
|
|
155
|
+
| `edited_message` | `[TelegramMessage]` | Message edited |
|
|
156
|
+
| `channel_post` | `[TelegramMessage]` | New post in a channel where the bot is admin |
|
|
157
|
+
| `edited_channel_post` | `[TelegramMessage]` | Channel post edited |
|
|
158
|
+
| `callback_query` | `[TelegramCallbackQuery]` | Inline keyboard button pressed |
|
|
159
|
+
| `inline_query` | `[TelegramInlineQuery]` | Inline-mode query (`@yourbot ...`) |
|
|
160
|
+
| `my_chat_member` | `[TelegramChatMemberUpdated]` | Bot's own membership status changed |
|
|
161
|
+
| `chat_member` | `[TelegramChatMemberUpdated]` | Other member's status changed (requires opt-in) |
|
|
162
|
+
| `telegram_update` | `[TelegramUpdate]` | Catch-all — every raw update |
|
|
163
|
+
|
|
164
|
+
### Reconnection
|
|
165
|
+
|
|
166
|
+
On recoverable errors (network failure, 5xx, transient API errors), the listener emits `disconnected` and retries with exponential backoff capped at 30 seconds. On `Unauthorized` (401) or `Conflict` (409 — another polling instance is running), it emits `error` and stops; restart your process after fixing the cause.
|
|
167
|
+
|
|
168
|
+
## TelegramBotCredentialManager
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const manager = new TelegramBotCredentialManager()
|
|
172
|
+
|
|
173
|
+
// Store credentials
|
|
174
|
+
await manager.setCredentials({ token, bot_id, bot_name })
|
|
175
|
+
|
|
176
|
+
// Retrieve current
|
|
177
|
+
const creds = await manager.getCredentials()
|
|
178
|
+
|
|
179
|
+
// Multi-bot support
|
|
180
|
+
const all = await manager.listAll()
|
|
181
|
+
await manager.setCurrent('deploy')
|
|
182
|
+
await manager.removeBot('alert')
|
|
183
|
+
await manager.clearCredentials()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Credentials are stored under `~/.config/agent-messenger/telegrambot-credentials.json` with `0600` file permissions. Override the directory with the `AGENT_MESSENGER_CONFIG_DIR` environment variable, or pass `new TelegramBotCredentialManager(customDir)`.
|
|
187
|
+
|
|
188
|
+
## Error Handling
|
|
189
|
+
|
|
190
|
+
All client methods throw `TelegramBotError` with a `code` property:
|
|
191
|
+
|
|
192
|
+
| Code | Meaning |
|
|
193
|
+
| ------------------- | ----------------------------------------------- |
|
|
194
|
+
| `missing_token` | Empty token passed to `login` |
|
|
195
|
+
| `not_authenticated` | Used a method before `.login()` |
|
|
196
|
+
| `no_credentials` | No stored credentials and none provided |
|
|
197
|
+
| `unauthorized` | 401 — invalid token |
|
|
198
|
+
| `conflict` | 409 — another polling instance running |
|
|
199
|
+
| `forbidden` | 403 — bot kicked or user hasn't started the bot |
|
|
200
|
+
| `bad_request` | 400 — usually invalid chat ID or message ID |
|
|
201
|
+
| `not_found` | 404 |
|
|
202
|
+
| `rate_limited` | 429 (after retries exhausted) |
|
|
203
|
+
| `network_error` | Fetch failed after retries |
|
|
204
|
+
| `invalid_response` | Telegram returned non-JSON |
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { TelegramBotError } from 'agent-messenger/telegrambot'
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await client.sendMessage(chatId, 'Hello')
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (error instanceof TelegramBotError && error.code === 'forbidden') {
|
|
213
|
+
console.log('User has not started the bot yet')
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
package/e2e/config.ts
CHANGED
|
@@ -242,6 +242,30 @@ export async function validateTelegramEnvironment(): Promise<boolean> {
|
|
|
242
242
|
return true
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
// Telegram Bot Test Environment
|
|
246
|
+
export const TELEGRAMBOT_TEST_CHAT_ID = process.env.E2E_TELEGRAMBOT_CHAT_ID || ''
|
|
247
|
+
|
|
248
|
+
export async function validateTelegramBotEnvironment(): Promise<boolean> {
|
|
249
|
+
if (!TELEGRAMBOT_TEST_CHAT_ID) {
|
|
250
|
+
console.warn('Skipping Telegram Bot E2E: set E2E_TELEGRAMBOT_CHAT_ID to run against a dedicated test chat.')
|
|
251
|
+
return false
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const { runCLI, parseJSON } = await import('./helpers')
|
|
255
|
+
|
|
256
|
+
const result = await runCLI('telegrambot', ['auth', 'status'])
|
|
257
|
+
if (result.exitCode !== 0) {
|
|
258
|
+
throw new Error('Telegram Bot authentication failed. Run: agent-telegrambot auth set <token>')
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const data = parseJSON<{ valid: boolean }>(result.stdout)
|
|
262
|
+
if (!data?.valid) {
|
|
263
|
+
throw new Error('Telegram Bot credentials invalid or expired. Run: agent-telegrambot auth set <token>')
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return true
|
|
267
|
+
}
|
|
268
|
+
|
|
245
269
|
// WhatsApp Test Environment
|
|
246
270
|
export const WHATSAPP_TEST_CHAT_ID = process.env.E2E_WHATSAPP_CHAT_ID || ''
|
|
247
271
|
|
package/e2e/helpers.ts
CHANGED
|
@@ -15,6 +15,7 @@ export async function runCLI(platform: string, args: string[]): Promise<CLIResul
|
|
|
15
15
|
channeltalk: 'agent-channeltalk',
|
|
16
16
|
webex: 'agent-webex',
|
|
17
17
|
telegram: 'agent-telegram',
|
|
18
|
+
telegrambot: 'agent-telegrambot',
|
|
18
19
|
whatsapp: 'agent-whatsapp',
|
|
19
20
|
whatsappbot: 'agent-whatsappbot',
|
|
20
21
|
line: 'agent-line',
|