@overpod/mcp-telegram 1.26.0 → 1.27.0

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.
Files changed (80) hide show
  1. package/dist/client.d.ts +12 -0
  2. package/dist/client.js +136 -0
  3. package/dist/index.js +15 -24
  4. package/dist/ipc-protocol.d.ts +19 -0
  5. package/dist/ipc-protocol.js +22 -0
  6. package/dist/lock.d.ts +12 -0
  7. package/dist/lock.js +83 -0
  8. package/dist/master.d.ts +1 -0
  9. package/dist/master.js +105 -0
  10. package/dist/rate-limiter.d.ts +1 -1
  11. package/dist/rate-limiter.js +8 -8
  12. package/dist/telegram-client.d.ts +6 -470
  13. package/dist/telegram-client.js +17 -874
  14. package/dist/telegram-helpers.d.ts +470 -0
  15. package/dist/telegram-helpers.js +870 -0
  16. package/dist/tools/account.js +7 -7
  17. package/dist/tools/boosts.js +4 -4
  18. package/dist/tools/chats.js +7 -7
  19. package/dist/tools/contacts.js +3 -3
  20. package/dist/tools/extras.js +3 -3
  21. package/dist/tools/group-calls.js +3 -3
  22. package/dist/tools/messages.js +17 -17
  23. package/dist/tools/quick-replies.js +3 -3
  24. package/dist/tools/reactions.js +2 -2
  25. package/dist/tools/shared.d.ts +3 -3
  26. package/dist/tools/shared.js +8 -7
  27. package/dist/tools/stars.js +3 -3
  28. package/dist/tools/stickers.js +5 -5
  29. package/dist/tools/stories.js +5 -5
  30. package/package.json +1 -1
  31. package/dist/__tests__/admin-log.test.d.ts +0 -1
  32. package/dist/__tests__/admin-log.test.js +0 -41
  33. package/dist/__tests__/approve-join-request.test.d.ts +0 -1
  34. package/dist/__tests__/approve-join-request.test.js +0 -107
  35. package/dist/__tests__/boosts.test.d.ts +0 -1
  36. package/dist/__tests__/boosts.test.js +0 -310
  37. package/dist/__tests__/broadcast-stats.test.d.ts +0 -1
  38. package/dist/__tests__/broadcast-stats.test.js +0 -172
  39. package/dist/__tests__/business-chat-links.test.d.ts +0 -1
  40. package/dist/__tests__/business-chat-links.test.js +0 -102
  41. package/dist/__tests__/get-message-buttons.test.d.ts +0 -1
  42. package/dist/__tests__/get-message-buttons.test.js +0 -122
  43. package/dist/__tests__/group-calls.test.d.ts +0 -1
  44. package/dist/__tests__/group-calls.test.js +0 -503
  45. package/dist/__tests__/inline-query-send.test.d.ts +0 -1
  46. package/dist/__tests__/inline-query-send.test.js +0 -94
  47. package/dist/__tests__/inline-query.test.d.ts +0 -1
  48. package/dist/__tests__/inline-query.test.js +0 -115
  49. package/dist/__tests__/megagroup-stats.test.d.ts +0 -1
  50. package/dist/__tests__/megagroup-stats.test.js +0 -166
  51. package/dist/__tests__/press-button.test.d.ts +0 -1
  52. package/dist/__tests__/press-button.test.js +0 -123
  53. package/dist/__tests__/quick-replies.test.d.ts +0 -1
  54. package/dist/__tests__/quick-replies.test.js +0 -245
  55. package/dist/__tests__/rate-limiter.test.d.ts +0 -1
  56. package/dist/__tests__/rate-limiter.test.js +0 -81
  57. package/dist/__tests__/reactions.test.d.ts +0 -1
  58. package/dist/__tests__/reactions.test.js +0 -23
  59. package/dist/__tests__/set-chat-permissions-merge.test.d.ts +0 -1
  60. package/dist/__tests__/set-chat-permissions-merge.test.js +0 -107
  61. package/dist/__tests__/set-chat-reactions.test.d.ts +0 -1
  62. package/dist/__tests__/set-chat-reactions.test.js +0 -129
  63. package/dist/__tests__/stars-status.test.d.ts +0 -1
  64. package/dist/__tests__/stars-status.test.js +0 -205
  65. package/dist/__tests__/stars-transactions.test.d.ts +0 -1
  66. package/dist/__tests__/stars-transactions.test.js +0 -82
  67. package/dist/__tests__/stories.test.d.ts +0 -1
  68. package/dist/__tests__/stories.test.js +0 -361
  69. package/dist/__tests__/toggle-anti-spam.test.d.ts +0 -1
  70. package/dist/__tests__/toggle-anti-spam.test.js +0 -80
  71. package/dist/__tests__/toggle-channel-signatures.test.d.ts +0 -1
  72. package/dist/__tests__/toggle-channel-signatures.test.js +0 -80
  73. package/dist/__tests__/toggle-forum-mode.test.d.ts +0 -1
  74. package/dist/__tests__/toggle-forum-mode.test.js +0 -80
  75. package/dist/__tests__/toggle-prehistory-hidden.test.d.ts +0 -1
  76. package/dist/__tests__/toggle-prehistory-hidden.test.js +0 -80
  77. package/dist/__tests__/tools/shared.test.d.ts +0 -1
  78. package/dist/__tests__/tools/shared.test.js +0 -110
  79. package/dist/__tests__/updates.test.d.ts +0 -1
  80. package/dist/__tests__/updates.test.js +0 -221
@@ -1,102 +0,0 @@
1
- import assert from "node:assert";
2
- import { describe, it } from "node:test";
3
- import { Api } from "telegram/tl/index.js";
4
- import { summarizeBusinessChatLink, summarizeBusinessChatLinks, TelegramService } from "../telegram-client.js";
5
- function makeService(invocations, responder) {
6
- const fakeClient = {
7
- invoke: async (req) => {
8
- invocations.push(req);
9
- return responder(req);
10
- },
11
- };
12
- const service = new TelegramService(1, "hash");
13
- const internals = service;
14
- internals.client = fakeClient;
15
- internals.connected = true;
16
- return service;
17
- }
18
- describe("summarizeBusinessChatLink", () => {
19
- it("maps link, message, title, views and entity count", () => {
20
- const link = new Api.BusinessChatLink({
21
- link: "https://t.me/message/abc",
22
- message: "Hello there",
23
- title: "Welcome",
24
- views: 42,
25
- entities: [
26
- new Api.MessageEntityBold({ offset: 0, length: 5 }),
27
- new Api.MessageEntityItalic({ offset: 6, length: 5 }),
28
- ],
29
- });
30
- const out = summarizeBusinessChatLink(link);
31
- assert.strictEqual(out.link, "https://t.me/message/abc");
32
- assert.strictEqual(out.message, "Hello there");
33
- assert.strictEqual(out.title, "Welcome");
34
- assert.strictEqual(out.views, 42);
35
- assert.strictEqual(out.entityCount, 2);
36
- });
37
- it("leaves title undefined and entityCount 0 when entities missing", () => {
38
- const link = new Api.BusinessChatLink({
39
- link: "https://t.me/message/xyz",
40
- message: "Plain",
41
- views: 0,
42
- });
43
- const out = summarizeBusinessChatLink(link);
44
- assert.strictEqual(out.title, undefined);
45
- assert.strictEqual(out.entityCount, 0);
46
- assert.strictEqual(out.views, 0);
47
- });
48
- });
49
- describe("summarizeBusinessChatLinks", () => {
50
- it("computes count from links length and maps each entry", () => {
51
- const resp = new Api.account.BusinessChatLinks({
52
- links: [
53
- new Api.BusinessChatLink({
54
- link: "https://t.me/message/a",
55
- message: "Hi",
56
- views: 1,
57
- }),
58
- new Api.BusinessChatLink({
59
- link: "https://t.me/message/b",
60
- message: "Hello",
61
- title: "Label",
62
- views: 5,
63
- }),
64
- ],
65
- chats: [],
66
- users: [],
67
- });
68
- const out = summarizeBusinessChatLinks(resp);
69
- assert.strictEqual(out.count, 2);
70
- assert.strictEqual(out.links.length, 2);
71
- assert.strictEqual(out.links[0].link, "https://t.me/message/a");
72
- assert.strictEqual(out.links[1].title, "Label");
73
- });
74
- it("handles empty link list", () => {
75
- const resp = new Api.account.BusinessChatLinks({ links: [], chats: [], users: [] });
76
- const out = summarizeBusinessChatLinks(resp);
77
- assert.strictEqual(out.count, 0);
78
- assert.deepStrictEqual(out.links, []);
79
- });
80
- });
81
- describe("TelegramService.getBusinessChatLinks", () => {
82
- it("invokes account.GetBusinessChatLinks and returns summary", async () => {
83
- const invocations = [];
84
- const service = makeService(invocations, () => new Api.account.BusinessChatLinks({
85
- links: [
86
- new Api.BusinessChatLink({
87
- link: "https://t.me/message/foo",
88
- message: "hey",
89
- views: 9,
90
- }),
91
- ],
92
- chats: [],
93
- users: [],
94
- }));
95
- const out = await service.getBusinessChatLinks();
96
- const call = invocations.find((r) => r instanceof Api.account.GetBusinessChatLinks);
97
- assert.ok(call);
98
- assert.strictEqual(out.count, 1);
99
- assert.strictEqual(out.links[0].link, "https://t.me/message/foo");
100
- assert.strictEqual(out.links[0].views, 9);
101
- });
102
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,122 +0,0 @@
1
- import assert from "node:assert";
2
- import { describe, it } from "node:test";
3
- import bigInt from "big-integer";
4
- import { Api } from "telegram/tl/index.js";
5
- import { TelegramService } from "../telegram-client.js";
6
- function makeService(chatEntity, messages) {
7
- const fakeClient = {
8
- getMessages: async (_entity, _opts) => messages,
9
- };
10
- const service = new TelegramService(1, "hash");
11
- const internals = service;
12
- internals.client = fakeClient;
13
- internals.connected = true;
14
- internals.resolveChat = async () => chatEntity;
15
- return service;
16
- }
17
- function makeChannel(id) {
18
- return new Api.Channel({
19
- id: bigInt(id),
20
- title: "t",
21
- photo: new Api.ChatPhotoEmpty(),
22
- date: 0,
23
- accessHash: bigInt(1),
24
- megagroup: true,
25
- });
26
- }
27
- function makeMessage(id, markup) {
28
- return new Api.Message({
29
- id,
30
- peerId: new Api.PeerChannel({ channelId: bigInt(100) }),
31
- date: 0,
32
- message: "hi",
33
- replyMarkup: markup,
34
- });
35
- }
36
- function inlineMarkup(buttons) {
37
- return new Api.ReplyInlineMarkup({
38
- rows: buttons.map((row) => new Api.KeyboardButtonRow({ buttons: row })),
39
- });
40
- }
41
- describe("TelegramService.getMessageButtons", () => {
42
- it("returns empty buttons and markupType='none' when message has no markup", async () => {
43
- const msg = makeMessage(1, undefined);
44
- const service = makeService(makeChannel(100), [msg]);
45
- const res = await service.getMessageButtons("100", 1);
46
- assert.deepStrictEqual(res, { markupType: "none", buttons: [] });
47
- });
48
- it("describes a callback button with base64 data", async () => {
49
- const data = Buffer.from("vote_yes");
50
- const msg = makeMessage(42, inlineMarkup([[new Api.KeyboardButtonCallback({ text: "Yes", data, requiresPassword: false })]]));
51
- const service = makeService(makeChannel(100), [msg]);
52
- const res = await service.getMessageButtons("100", 42);
53
- assert.strictEqual(res.markupType, "ReplyInlineMarkup");
54
- assert.strictEqual(res.buttons.length, 1);
55
- const b = res.buttons[0];
56
- assert.strictEqual(b.row, 0);
57
- assert.strictEqual(b.col, 0);
58
- assert.strictEqual(b.type, "KeyboardButtonCallback");
59
- assert.strictEqual(b.label, "Yes");
60
- assert.ok(b.data, "data is set");
61
- assert.strictEqual(Buffer.from(b.data, "base64").toString(), "vote_yes");
62
- assert.strictEqual(b.requiresPassword, undefined);
63
- });
64
- it("flags requiresPassword callback buttons", async () => {
65
- const msg = makeMessage(1, inlineMarkup([
66
- [new Api.KeyboardButtonCallback({ text: "Admin", data: Buffer.from("x"), requiresPassword: true })],
67
- ]));
68
- const service = makeService(makeChannel(100), [msg]);
69
- const res = await service.getMessageButtons("100", 1);
70
- assert.strictEqual(res.buttons[0].requiresPassword, true);
71
- });
72
- it("describes URL, switch-inline and copy buttons with type-specific fields", async () => {
73
- const msg = makeMessage(2, inlineMarkup([
74
- [
75
- new Api.KeyboardButtonUrl({ text: "Open", url: "https://x.test" }),
76
- new Api.KeyboardButtonSwitchInline({ text: "Inline", query: "q", samePeer: true }),
77
- ],
78
- [new Api.KeyboardButtonCopy({ text: "Copy", copyText: "abc" })],
79
- ]));
80
- const service = makeService(makeChannel(100), [msg]);
81
- const res = await service.getMessageButtons("100", 2);
82
- assert.strictEqual(res.buttons.length, 3);
83
- const [urlB, inlineB, copyB] = res.buttons;
84
- assert.strictEqual(urlB.type, "KeyboardButtonUrl");
85
- assert.strictEqual(urlB.url, "https://x.test");
86
- assert.strictEqual(urlB.row, 0);
87
- assert.strictEqual(urlB.col, 0);
88
- assert.strictEqual(inlineB.type, "KeyboardButtonSwitchInline");
89
- assert.strictEqual(inlineB.switchQuery, "q");
90
- assert.strictEqual(inlineB.samePeer, true);
91
- assert.strictEqual(inlineB.row, 0);
92
- assert.strictEqual(inlineB.col, 1);
93
- assert.strictEqual(copyB.type, "KeyboardButtonCopy");
94
- assert.strictEqual(copyB.copyText, "abc");
95
- assert.strictEqual(copyB.row, 1);
96
- assert.strictEqual(copyB.col, 0);
97
- });
98
- it("preserves markupType for non-inline reply keyboards with buttons", async () => {
99
- const markup = new Api.ReplyKeyboardMarkup({
100
- rows: [new Api.KeyboardButtonRow({ buttons: [new Api.KeyboardButton({ text: "x" })] })],
101
- });
102
- const msg = makeMessage(3, markup);
103
- const service = makeService(makeChannel(100), [msg]);
104
- const res = await service.getMessageButtons("100", 3);
105
- assert.strictEqual(res.markupType, "ReplyKeyboardMarkup");
106
- assert.strictEqual(res.buttons.length, 1);
107
- assert.strictEqual(res.buttons[0].type, "KeyboardButton");
108
- assert.strictEqual(res.buttons[0].label, "x");
109
- });
110
- it("returns empty buttons for ReplyKeyboardHide-like markup without rows", async () => {
111
- const markup = new Api.ReplyKeyboardHide({ selective: false });
112
- const msg = makeMessage(4, markup);
113
- const service = makeService(makeChannel(100), [msg]);
114
- const res = await service.getMessageButtons("100", 4);
115
- assert.strictEqual(res.markupType, "ReplyKeyboardHide");
116
- assert.deepStrictEqual(res.buttons, []);
117
- });
118
- it("rejects when message is not found", async () => {
119
- const service = makeService(makeChannel(100), []);
120
- await assert.rejects(service.getMessageButtons("100", 999), /not found/i);
121
- });
122
- });
@@ -1 +0,0 @@
1
- export {};