@tool-bridge/server 0.16.0 → 0.17.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.
- package/dist/{airtable-S3T4TAN7.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
- package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +57 -50
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
|
@@ -1,47 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
booleanValue,
|
|
7
|
+
compactDefined,
|
|
8
|
+
finiteNumber,
|
|
9
|
+
trimmedText
|
|
10
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
11
|
import {
|
|
2
12
|
createProviderPlugin,
|
|
3
13
|
requireApiKey,
|
|
4
14
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YASUMV2K.js";
|
|
6
16
|
import {
|
|
7
|
-
assertPublicHttpUrl
|
|
8
|
-
|
|
9
|
-
} from "./chunk-2O27H4Y2.js";
|
|
10
|
-
import "./chunk-GKX72JMJ.js";
|
|
17
|
+
assertPublicHttpUrl
|
|
18
|
+
} from "./chunk-U5UHT7CX.js";
|
|
11
19
|
import {
|
|
12
20
|
TBError,
|
|
13
21
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-RVWZN3CI.js";
|
|
23
|
+
import "./chunk-U67V476Y.js";
|
|
16
24
|
|
|
17
25
|
// ../plugins/src/telegram/api.ts
|
|
18
26
|
var SERVICE = "telegram";
|
|
19
27
|
var API_BASE = "https://api.telegram.org";
|
|
20
28
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
21
|
-
|
|
22
|
-
if (typeof value !== "string") return void 0;
|
|
23
|
-
const trimmed = value.trim();
|
|
24
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
25
|
-
}
|
|
26
|
-
function num(value) {
|
|
27
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
28
|
-
}
|
|
29
|
-
function bool(value) {
|
|
30
|
-
return typeof value === "boolean" ? value : void 0;
|
|
31
|
-
}
|
|
32
|
-
function record(value) {
|
|
33
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
34
|
-
}
|
|
29
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
35
30
|
function asRecord(value) {
|
|
36
|
-
const result =
|
|
31
|
+
const result = asJsonObject(value);
|
|
37
32
|
if (result === void 0) {
|
|
38
33
|
throw new TBError("unavailable", "Telegram \u8FD4\u56DE\u4E86\u975E\u9884\u671F\u7684\u5BF9\u8C61\u8D1F\u8F7D", { retryable: true });
|
|
39
34
|
}
|
|
40
35
|
return result;
|
|
41
36
|
}
|
|
42
|
-
function compact(value) {
|
|
43
|
-
return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
|
|
44
|
-
}
|
|
45
37
|
function assertBotToken(botToken) {
|
|
46
38
|
if (botToken.length === 0 || /[/?#\s]/u.test(botToken)) {
|
|
47
39
|
throw new TBError("invalid_argument", "telegram bot token is malformed");
|
|
@@ -51,46 +43,45 @@ function methodUrl(botToken, method) {
|
|
|
51
43
|
assertBotToken(botToken);
|
|
52
44
|
return `${API_BASE}/bot${botToken}/${method}`;
|
|
53
45
|
}
|
|
54
|
-
|
|
46
|
+
function readEnvelope(response) {
|
|
55
47
|
if ((response.headers.get("content-type") ?? "").includes("application/json")) {
|
|
56
|
-
return
|
|
48
|
+
return response.bodyKind === "json" ? asJsonObject(response.data) ?? {} : {};
|
|
57
49
|
}
|
|
58
|
-
const body =
|
|
50
|
+
const body = typeof response.data === "string" ? response.data : "";
|
|
59
51
|
return {
|
|
60
52
|
ok: false,
|
|
61
53
|
description: body === "" ? `telegram request failed with ${response.status}` : body,
|
|
62
54
|
error_code: response.status
|
|
63
55
|
};
|
|
64
56
|
}
|
|
65
|
-
function telegramError(
|
|
66
|
-
const code =
|
|
57
|
+
function telegramError(statusCode, responseOk, payload, method) {
|
|
58
|
+
const code = finiteNumber(payload.error_code) ?? (responseOk ? void 0 : statusCode);
|
|
67
59
|
const status = code ?? 502;
|
|
68
|
-
const description =
|
|
60
|
+
const description = trimmedText(payload.description) ?? `telegram ${method} request failed with ${status}`;
|
|
69
61
|
if (status === 429) {
|
|
70
|
-
const retryAfter =
|
|
62
|
+
const retryAfter = finiteNumber(asJsonObject(payload.parameters)?.retry_after);
|
|
71
63
|
return upstreamError(429, retryAfter === void 0 ? description : `${description} Retry after ${retryAfter} seconds.`);
|
|
72
64
|
}
|
|
73
65
|
return upstreamError(status, description);
|
|
74
66
|
}
|
|
75
67
|
async function request(ctx, method, body) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!response.ok || payload.ok !== true) throw telegramError(response, payload, method);
|
|
68
|
+
const botToken = requireApiKey(ctx, SERVICE);
|
|
69
|
+
const result = await http.request({
|
|
70
|
+
path: methodUrl(botToken, method),
|
|
71
|
+
method: body === void 0 ? "GET" : "POST",
|
|
72
|
+
...body === void 0 ? {} : { json: body },
|
|
73
|
+
responseType: "auto",
|
|
74
|
+
invalidJson: "text",
|
|
75
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
76
|
+
sensitiveValues: [botToken],
|
|
77
|
+
mapError: (context) => {
|
|
78
|
+
const payload2 = readEnvelope(context);
|
|
79
|
+
return telegramError(context.status, false, payload2, method);
|
|
80
|
+
},
|
|
81
|
+
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `telegram ${method} \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`) : upstreamError(502, `telegram ${method} \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`)
|
|
82
|
+
});
|
|
83
|
+
const payload = readEnvelope(result);
|
|
84
|
+
if (payload.ok !== true) throw telegramError(result.status, true, payload, method);
|
|
94
85
|
if (payload.result === void 0) {
|
|
95
86
|
throw new TBError("unavailable", `telegram ${method} response did not include result`, { retryable: true });
|
|
96
87
|
}
|
|
@@ -108,19 +99,19 @@ function jsonLike(value) {
|
|
|
108
99
|
} catch {
|
|
109
100
|
throw new TBError("invalid_argument", "invalid JSON string input");
|
|
110
101
|
}
|
|
111
|
-
const result =
|
|
102
|
+
const result = asJsonObject(parsed);
|
|
112
103
|
if (result === void 0) throw new TBError("invalid_argument", "JSON string input must decode to an object");
|
|
113
104
|
return result;
|
|
114
105
|
}
|
|
115
|
-
return
|
|
106
|
+
return asJsonObject(value);
|
|
116
107
|
}
|
|
117
108
|
function publicUrl(value) {
|
|
118
|
-
const candidate =
|
|
109
|
+
const candidate = trimmedText(value);
|
|
119
110
|
if (candidate === void 0) return void 0;
|
|
120
111
|
return assertPublicHttpUrl(candidate).toString();
|
|
121
112
|
}
|
|
122
113
|
function urlOrFileId(value) {
|
|
123
|
-
const candidate =
|
|
114
|
+
const candidate = trimmedText(value);
|
|
124
115
|
if (candidate === void 0 || !/^https?:\/\//iu.test(candidate)) return value;
|
|
125
116
|
return publicUrl(candidate);
|
|
126
117
|
}
|
|
@@ -129,24 +120,24 @@ function normalizeUser(value) {
|
|
|
129
120
|
id: Number(value.id),
|
|
130
121
|
isBot: Boolean(value.is_bot),
|
|
131
122
|
firstName: String(value.first_name ?? ""),
|
|
132
|
-
username:
|
|
133
|
-
languageCode:
|
|
134
|
-
canJoinGroups:
|
|
135
|
-
canReadAllGroupMessages:
|
|
136
|
-
supportsInlineQueries:
|
|
137
|
-
canConnectToBusiness:
|
|
138
|
-
hasMainWebApp:
|
|
123
|
+
username: trimmedText(value.username),
|
|
124
|
+
languageCode: trimmedText(value.language_code),
|
|
125
|
+
canJoinGroups: booleanValue(value.can_join_groups),
|
|
126
|
+
canReadAllGroupMessages: booleanValue(value.can_read_all_group_messages),
|
|
127
|
+
supportsInlineQueries: booleanValue(value.supports_inline_queries),
|
|
128
|
+
canConnectToBusiness: booleanValue(value.can_connect_to_business),
|
|
129
|
+
hasMainWebApp: booleanValue(value.has_main_web_app)
|
|
139
130
|
};
|
|
140
131
|
}
|
|
141
132
|
function normalizeChat(value) {
|
|
142
133
|
return {
|
|
143
134
|
id: Number(value.id),
|
|
144
135
|
type: String(value.type ?? ""),
|
|
145
|
-
title:
|
|
146
|
-
username:
|
|
147
|
-
firstName:
|
|
148
|
-
lastName:
|
|
149
|
-
isForum:
|
|
136
|
+
title: trimmedText(value.title),
|
|
137
|
+
username: trimmedText(value.username),
|
|
138
|
+
firstName: trimmedText(value.first_name),
|
|
139
|
+
lastName: trimmedText(value.last_name),
|
|
140
|
+
isForum: booleanValue(value.is_forum)
|
|
150
141
|
};
|
|
151
142
|
}
|
|
152
143
|
function normalizePhotoSize(value) {
|
|
@@ -155,16 +146,16 @@ function normalizePhotoSize(value) {
|
|
|
155
146
|
fileUniqueId: String(value.file_unique_id ?? ""),
|
|
156
147
|
width: Number(value.width),
|
|
157
148
|
height: Number(value.height),
|
|
158
|
-
fileSize:
|
|
149
|
+
fileSize: finiteNumber(value.file_size)
|
|
159
150
|
};
|
|
160
151
|
}
|
|
161
152
|
function normalizeDocument(value) {
|
|
162
153
|
return {
|
|
163
154
|
fileId: String(value.file_id ?? ""),
|
|
164
155
|
fileUniqueId: String(value.file_unique_id ?? ""),
|
|
165
|
-
fileName:
|
|
166
|
-
mimeType:
|
|
167
|
-
fileSize:
|
|
156
|
+
fileName: trimmedText(value.file_name),
|
|
157
|
+
mimeType: trimmedText(value.mime_type),
|
|
158
|
+
fileSize: finiteNumber(value.file_size)
|
|
168
159
|
};
|
|
169
160
|
}
|
|
170
161
|
function normalizeVideoQuality(value) {
|
|
@@ -174,7 +165,7 @@ function normalizeVideoQuality(value) {
|
|
|
174
165
|
width: Number(value.width),
|
|
175
166
|
height: Number(value.height),
|
|
176
167
|
codec: String(value.codec ?? ""),
|
|
177
|
-
fileSize:
|
|
168
|
+
fileSize: finiteNumber(value.file_size)
|
|
178
169
|
};
|
|
179
170
|
}
|
|
180
171
|
function normalizeVideo(value) {
|
|
@@ -186,11 +177,11 @@ function normalizeVideo(value) {
|
|
|
186
177
|
duration: Number(value.duration),
|
|
187
178
|
thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
|
|
188
179
|
cover: Array.isArray(value.cover) ? value.cover.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
|
|
189
|
-
startTimestamp:
|
|
180
|
+
startTimestamp: finiteNumber(value.start_timestamp),
|
|
190
181
|
qualities: Array.isArray(value.qualities) ? value.qualities.map((item) => normalizeVideoQuality(asRecord(item))) : void 0,
|
|
191
|
-
fileName:
|
|
192
|
-
mimeType:
|
|
193
|
-
fileSize:
|
|
182
|
+
fileName: trimmedText(value.file_name),
|
|
183
|
+
mimeType: trimmedText(value.mime_type),
|
|
184
|
+
fileSize: finiteNumber(value.file_size)
|
|
194
185
|
};
|
|
195
186
|
}
|
|
196
187
|
function normalizeAudio(value) {
|
|
@@ -198,11 +189,11 @@ function normalizeAudio(value) {
|
|
|
198
189
|
fileId: String(value.file_id ?? ""),
|
|
199
190
|
fileUniqueId: String(value.file_unique_id ?? ""),
|
|
200
191
|
duration: Number(value.duration),
|
|
201
|
-
performer:
|
|
202
|
-
title:
|
|
203
|
-
fileName:
|
|
204
|
-
mimeType:
|
|
205
|
-
fileSize:
|
|
192
|
+
performer: trimmedText(value.performer),
|
|
193
|
+
title: trimmedText(value.title),
|
|
194
|
+
fileName: trimmedText(value.file_name),
|
|
195
|
+
mimeType: trimmedText(value.mime_type),
|
|
196
|
+
fileSize: finiteNumber(value.file_size),
|
|
206
197
|
thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0
|
|
207
198
|
};
|
|
208
199
|
}
|
|
@@ -211,8 +202,8 @@ function normalizeVoice(value) {
|
|
|
211
202
|
fileId: String(value.file_id ?? ""),
|
|
212
203
|
fileUniqueId: String(value.file_unique_id ?? ""),
|
|
213
204
|
duration: Number(value.duration),
|
|
214
|
-
mimeType:
|
|
215
|
-
fileSize:
|
|
205
|
+
mimeType: trimmedText(value.mime_type),
|
|
206
|
+
fileSize: finiteNumber(value.file_size)
|
|
216
207
|
};
|
|
217
208
|
}
|
|
218
209
|
function normalizeAnimation(value) {
|
|
@@ -223,28 +214,28 @@ function normalizeAnimation(value) {
|
|
|
223
214
|
height: Number(value.height),
|
|
224
215
|
duration: Number(value.duration),
|
|
225
216
|
thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
|
|
226
|
-
fileName:
|
|
227
|
-
mimeType:
|
|
228
|
-
fileSize:
|
|
217
|
+
fileName: trimmedText(value.file_name),
|
|
218
|
+
mimeType: trimmedText(value.mime_type),
|
|
219
|
+
fileSize: finiteNumber(value.file_size)
|
|
229
220
|
};
|
|
230
221
|
}
|
|
231
222
|
function normalizeContact(value) {
|
|
232
223
|
return {
|
|
233
224
|
phoneNumber: String(value.phone_number ?? ""),
|
|
234
225
|
firstName: String(value.first_name ?? ""),
|
|
235
|
-
lastName:
|
|
236
|
-
userId:
|
|
237
|
-
vcard:
|
|
226
|
+
lastName: trimmedText(value.last_name),
|
|
227
|
+
userId: finiteNumber(value.user_id),
|
|
228
|
+
vcard: trimmedText(value.vcard)
|
|
238
229
|
};
|
|
239
230
|
}
|
|
240
231
|
function normalizeLocation(value) {
|
|
241
232
|
return {
|
|
242
233
|
latitude: Number(value.latitude),
|
|
243
234
|
longitude: Number(value.longitude),
|
|
244
|
-
horizontalAccuracy:
|
|
245
|
-
livePeriod:
|
|
246
|
-
heading:
|
|
247
|
-
proximityAlertRadius:
|
|
235
|
+
horizontalAccuracy: finiteNumber(value.horizontal_accuracy),
|
|
236
|
+
livePeriod: finiteNumber(value.live_period),
|
|
237
|
+
heading: finiteNumber(value.heading),
|
|
238
|
+
proximityAlertRadius: finiteNumber(value.proximity_alert_radius)
|
|
248
239
|
};
|
|
249
240
|
}
|
|
250
241
|
function normalizeVenue(value) {
|
|
@@ -252,10 +243,10 @@ function normalizeVenue(value) {
|
|
|
252
243
|
location: normalizeLocation(asRecord(value.location)),
|
|
253
244
|
title: String(value.title ?? ""),
|
|
254
245
|
address: String(value.address ?? ""),
|
|
255
|
-
foursquareId:
|
|
256
|
-
foursquareType:
|
|
257
|
-
googlePlaceId:
|
|
258
|
-
googlePlaceType:
|
|
246
|
+
foursquareId: trimmedText(value.foursquare_id),
|
|
247
|
+
foursquareType: trimmedText(value.foursquare_type),
|
|
248
|
+
googlePlaceId: trimmedText(value.google_place_id),
|
|
249
|
+
googlePlaceType: trimmedText(value.google_place_type)
|
|
259
250
|
};
|
|
260
251
|
}
|
|
261
252
|
function normalizeDice(value) {
|
|
@@ -277,10 +268,10 @@ function normalizePoll(value) {
|
|
|
277
268
|
isAnonymous: Boolean(value.is_anonymous),
|
|
278
269
|
type: value.type === "quiz" ? "quiz" : "regular",
|
|
279
270
|
allowsMultipleAnswers: Boolean(value.allows_multiple_answers),
|
|
280
|
-
closeDate:
|
|
281
|
-
openPeriod:
|
|
282
|
-
explanation:
|
|
283
|
-
correctOptionId:
|
|
271
|
+
closeDate: finiteNumber(value.close_date),
|
|
272
|
+
openPeriod: finiteNumber(value.open_period),
|
|
273
|
+
explanation: trimmedText(value.explanation),
|
|
274
|
+
correctOptionId: finiteNumber(value.correct_option_id)
|
|
284
275
|
};
|
|
285
276
|
}
|
|
286
277
|
function normalizeMessage(value) {
|
|
@@ -290,22 +281,22 @@ function normalizeMessage(value) {
|
|
|
290
281
|
chat: normalizeChat(asRecord(value.chat)),
|
|
291
282
|
from: value.from ? normalizeUser(asRecord(value.from)) : void 0,
|
|
292
283
|
senderChat: value.sender_chat ? normalizeChat(asRecord(value.sender_chat)) : void 0,
|
|
293
|
-
text:
|
|
294
|
-
caption:
|
|
284
|
+
text: trimmedText(value.text),
|
|
285
|
+
caption: trimmedText(value.caption),
|
|
295
286
|
photo: Array.isArray(value.photo) ? value.photo.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
|
|
296
287
|
document: value.document ? normalizeDocument(asRecord(value.document)) : void 0,
|
|
297
288
|
location: value.location ? normalizeLocation(asRecord(value.location)) : void 0,
|
|
298
289
|
poll: value.poll ? normalizePoll(asRecord(value.poll)) : void 0,
|
|
299
290
|
entities: Array.isArray(value.entities) ? value.entities.map((item) => asRecord(item)) : void 0,
|
|
300
291
|
captionEntities: Array.isArray(value.caption_entities) ? value.caption_entities.map((item) => asRecord(item)) : void 0,
|
|
301
|
-
forwardDate:
|
|
292
|
+
forwardDate: finiteNumber(value.forward_date),
|
|
302
293
|
forwardFrom: value.forward_from ? normalizeUser(asRecord(value.forward_from)) : void 0,
|
|
303
294
|
forwardFromChat: value.forward_from_chat ? normalizeChat(asRecord(value.forward_from_chat)) : void 0,
|
|
304
|
-
forwardFromMessageId:
|
|
305
|
-
forwardSignature:
|
|
306
|
-
forwardSenderName:
|
|
295
|
+
forwardFromMessageId: finiteNumber(value.forward_from_message_id),
|
|
296
|
+
forwardSignature: trimmedText(value.forward_signature),
|
|
297
|
+
forwardSenderName: trimmedText(value.forward_sender_name),
|
|
307
298
|
linkPreviewOptions: value.link_preview_options ? asRecord(value.link_preview_options) : void 0,
|
|
308
|
-
businessConnectionId:
|
|
299
|
+
businessConnectionId: trimmedText(value.business_connection_id),
|
|
309
300
|
video: value.video ? normalizeVideo(asRecord(value.video)) : void 0,
|
|
310
301
|
audio: value.audio ? normalizeAudio(asRecord(value.audio)) : void 0,
|
|
311
302
|
voice: value.voice ? normalizeVoice(asRecord(value.voice)) : void 0,
|
|
@@ -317,20 +308,20 @@ function normalizeMessage(value) {
|
|
|
317
308
|
}
|
|
318
309
|
function normalizeBusinessBotRights(value) {
|
|
319
310
|
return {
|
|
320
|
-
canReply:
|
|
321
|
-
canReadMessages:
|
|
322
|
-
canDeleteSentMessages:
|
|
323
|
-
canDeleteAllMessages:
|
|
324
|
-
canEditName:
|
|
325
|
-
canEditBio:
|
|
326
|
-
canEditProfilePhoto:
|
|
327
|
-
canEditUsername:
|
|
328
|
-
canChangeGiftSettings:
|
|
329
|
-
canViewGiftsAndStars:
|
|
330
|
-
canConvertGiftsToStars:
|
|
331
|
-
canTransferAndUpgradeGifts:
|
|
332
|
-
canTransferStars:
|
|
333
|
-
canManageStories:
|
|
311
|
+
canReply: booleanValue(value.can_reply),
|
|
312
|
+
canReadMessages: booleanValue(value.can_read_messages),
|
|
313
|
+
canDeleteSentMessages: booleanValue(value.can_delete_sent_messages),
|
|
314
|
+
canDeleteAllMessages: booleanValue(value.can_delete_all_messages),
|
|
315
|
+
canEditName: booleanValue(value.can_edit_name),
|
|
316
|
+
canEditBio: booleanValue(value.can_edit_bio),
|
|
317
|
+
canEditProfilePhoto: booleanValue(value.can_edit_profile_photo),
|
|
318
|
+
canEditUsername: booleanValue(value.can_edit_username),
|
|
319
|
+
canChangeGiftSettings: booleanValue(value.can_change_gift_settings),
|
|
320
|
+
canViewGiftsAndStars: booleanValue(value.can_view_gifts_and_stars),
|
|
321
|
+
canConvertGiftsToStars: booleanValue(value.can_convert_gifts_to_stars),
|
|
322
|
+
canTransferAndUpgradeGifts: booleanValue(value.can_transfer_and_upgrade_gifts),
|
|
323
|
+
canTransferStars: booleanValue(value.can_transfer_stars),
|
|
324
|
+
canManageStories: booleanValue(value.can_manage_stories)
|
|
334
325
|
};
|
|
335
326
|
}
|
|
336
327
|
function normalizeBusinessConnection(value) {
|
|
@@ -369,11 +360,11 @@ function normalizeWebhookInfo(value) {
|
|
|
369
360
|
url: String(value.url ?? ""),
|
|
370
361
|
hasCustomCertificate: Boolean(value.has_custom_certificate),
|
|
371
362
|
pendingUpdateCount: Number(value.pending_update_count ?? 0),
|
|
372
|
-
ipAddress:
|
|
373
|
-
lastErrorDate:
|
|
374
|
-
lastErrorMessage:
|
|
375
|
-
lastSynchronizationErrorDate:
|
|
376
|
-
maxConnections:
|
|
363
|
+
ipAddress: trimmedText(value.ip_address),
|
|
364
|
+
lastErrorDate: finiteNumber(value.last_error_date),
|
|
365
|
+
lastErrorMessage: trimmedText(value.last_error_message),
|
|
366
|
+
lastSynchronizationErrorDate: finiteNumber(value.last_synchronization_error_date),
|
|
367
|
+
maxConnections: finiteNumber(value.max_connections),
|
|
377
368
|
allowedUpdates: Array.isArray(value.allowed_updates) ? value.allowed_updates.map((item) => String(item)) : void 0
|
|
378
369
|
};
|
|
379
370
|
}
|
|
@@ -381,26 +372,26 @@ function normalizeChatMember(value) {
|
|
|
381
372
|
return {
|
|
382
373
|
status: String(value.status ?? ""),
|
|
383
374
|
user: normalizeUser(asRecord(value.user)),
|
|
384
|
-
customTitle:
|
|
385
|
-
isAnonymous:
|
|
386
|
-
untilDate:
|
|
387
|
-
canBeEdited:
|
|
388
|
-
canChangeInfo:
|
|
389
|
-
canManageChat:
|
|
390
|
-
canInviteUsers:
|
|
391
|
-
canPinMessages:
|
|
392
|
-
canEditMessages:
|
|
393
|
-
canPostMessages:
|
|
394
|
-
canDeleteMessages:
|
|
395
|
-
canPromoteMembers:
|
|
396
|
-
canRestrictMembers:
|
|
397
|
-
canManageVideoChats:
|
|
398
|
-
canManageTopics:
|
|
375
|
+
customTitle: trimmedText(value.custom_title),
|
|
376
|
+
isAnonymous: booleanValue(value.is_anonymous),
|
|
377
|
+
untilDate: finiteNumber(value.until_date),
|
|
378
|
+
canBeEdited: booleanValue(value.can_be_edited),
|
|
379
|
+
canChangeInfo: booleanValue(value.can_change_info),
|
|
380
|
+
canManageChat: booleanValue(value.can_manage_chat),
|
|
381
|
+
canInviteUsers: booleanValue(value.can_invite_users),
|
|
382
|
+
canPinMessages: booleanValue(value.can_pin_messages),
|
|
383
|
+
canEditMessages: booleanValue(value.can_edit_messages),
|
|
384
|
+
canPostMessages: booleanValue(value.can_post_messages),
|
|
385
|
+
canDeleteMessages: booleanValue(value.can_delete_messages),
|
|
386
|
+
canPromoteMembers: booleanValue(value.can_promote_members),
|
|
387
|
+
canRestrictMembers: booleanValue(value.can_restrict_members),
|
|
388
|
+
canManageVideoChats: booleanValue(value.can_manage_video_chats),
|
|
389
|
+
canManageTopics: booleanValue(value.can_manage_topics)
|
|
399
390
|
};
|
|
400
391
|
}
|
|
401
392
|
function normalizeChatPermissions(value) {
|
|
402
393
|
const permissions = asRecord(value);
|
|
403
|
-
return
|
|
394
|
+
return compactDefined({
|
|
404
395
|
can_send_messages: permissions.canSendMessages,
|
|
405
396
|
can_send_audios: permissions.canSendAudios,
|
|
406
397
|
can_send_documents: permissions.canSendDocuments,
|
|
@@ -424,12 +415,12 @@ function normalizeChatInviteLink(value) {
|
|
|
424
415
|
createsJoinRequest: Boolean(value.creates_join_request),
|
|
425
416
|
isPrimary: Boolean(value.is_primary),
|
|
426
417
|
isRevoked: Boolean(value.is_revoked),
|
|
427
|
-
name:
|
|
428
|
-
expireDate:
|
|
429
|
-
memberLimit:
|
|
430
|
-
pendingJoinRequestCount:
|
|
431
|
-
subscriptionPeriod:
|
|
432
|
-
subscriptionPrice:
|
|
418
|
+
name: trimmedText(value.name),
|
|
419
|
+
expireDate: finiteNumber(value.expire_date),
|
|
420
|
+
memberLimit: finiteNumber(value.member_limit),
|
|
421
|
+
pendingJoinRequestCount: finiteNumber(value.pending_join_request_count),
|
|
422
|
+
subscriptionPeriod: finiteNumber(value.subscription_period),
|
|
423
|
+
subscriptionPrice: finiteNumber(value.subscription_price)
|
|
433
424
|
};
|
|
434
425
|
}
|
|
435
426
|
function assertIncreasingMessageIds(value) {
|
|
@@ -459,7 +450,7 @@ function asArray(value) {
|
|
|
459
450
|
return value;
|
|
460
451
|
}
|
|
461
452
|
async function getUpdates(input, ctx) {
|
|
462
|
-
const result = await request(ctx, "getUpdates",
|
|
453
|
+
const result = await request(ctx, "getUpdates", compactDefined({
|
|
463
454
|
offset: input.offset,
|
|
464
455
|
limit: input.limit,
|
|
465
456
|
timeout: input.timeout,
|
|
@@ -468,7 +459,7 @@ async function getUpdates(input, ctx) {
|
|
|
468
459
|
return { updates: asArray(result).map((update) => normalizeUpdate(asRecord(update))) };
|
|
469
460
|
}
|
|
470
461
|
async function sendMessage(input, ctx) {
|
|
471
|
-
const result = await request(ctx, "sendMessage",
|
|
462
|
+
const result = await request(ctx, "sendMessage", compactDefined({
|
|
472
463
|
business_connection_id: input.businessConnectionId,
|
|
473
464
|
chat_id: input.chatId,
|
|
474
465
|
text: input.text,
|
|
@@ -484,7 +475,7 @@ async function sendMessage(input, ctx) {
|
|
|
484
475
|
return normalizeMessage(asRecord(result));
|
|
485
476
|
}
|
|
486
477
|
async function copyMessage(input, ctx) {
|
|
487
|
-
const result = asRecord(await request(ctx, "copyMessage",
|
|
478
|
+
const result = asRecord(await request(ctx, "copyMessage", compactDefined({
|
|
488
479
|
chat_id: input.chatId,
|
|
489
480
|
from_chat_id: input.fromChatId,
|
|
490
481
|
message_id: input.messageId,
|
|
@@ -499,7 +490,7 @@ async function copyMessage(input, ctx) {
|
|
|
499
490
|
}
|
|
500
491
|
async function transferMessages(ctx, method, input) {
|
|
501
492
|
assertIncreasingMessageIds(input.messageIds);
|
|
502
|
-
const result = await request(ctx, method,
|
|
493
|
+
const result = await request(ctx, method, compactDefined({
|
|
503
494
|
chat_id: input.chatId,
|
|
504
495
|
from_chat_id: input.fromChatId,
|
|
505
496
|
message_ids: input.messageIds,
|
|
@@ -523,7 +514,7 @@ function deleteMessages(input, ctx) {
|
|
|
523
514
|
});
|
|
524
515
|
}
|
|
525
516
|
function setMessageReaction(input, ctx) {
|
|
526
|
-
return booleanAction(ctx, "setMessageReaction",
|
|
517
|
+
return booleanAction(ctx, "setMessageReaction", compactDefined({
|
|
527
518
|
chat_id: input.chatId,
|
|
528
519
|
message_id: input.messageId,
|
|
529
520
|
reaction: input.reaction,
|
|
@@ -531,7 +522,7 @@ function setMessageReaction(input, ctx) {
|
|
|
531
522
|
}));
|
|
532
523
|
}
|
|
533
524
|
function sendChatAction(input, ctx) {
|
|
534
|
-
return booleanAction(ctx, "sendChatAction",
|
|
525
|
+
return booleanAction(ctx, "sendChatAction", compactDefined({
|
|
535
526
|
business_connection_id: input.businessConnectionId,
|
|
536
527
|
chat_id: input.chatId,
|
|
537
528
|
message_thread_id: input.messageThreadId,
|
|
@@ -540,7 +531,7 @@ function sendChatAction(input, ctx) {
|
|
|
540
531
|
}
|
|
541
532
|
async function sendMedia(ctx, method, field, input) {
|
|
542
533
|
const source = input;
|
|
543
|
-
const result = await request(ctx, method,
|
|
534
|
+
const result = await request(ctx, method, compactDefined({
|
|
544
535
|
business_connection_id: input.businessConnectionId,
|
|
545
536
|
chat_id: input.chatId,
|
|
546
537
|
message_thread_id: input.messageThreadId,
|
|
@@ -575,7 +566,7 @@ function sendAnimation(input, ctx) {
|
|
|
575
566
|
return sendMedia(ctx, "sendAnimation", "animation", input);
|
|
576
567
|
}
|
|
577
568
|
async function sendMediaGroup(input, ctx) {
|
|
578
|
-
const result = await request(ctx, "sendMediaGroup",
|
|
569
|
+
const result = await request(ctx, "sendMediaGroup", compactDefined({
|
|
579
570
|
business_connection_id: input.businessConnectionId,
|
|
580
571
|
chat_id: input.chatId,
|
|
581
572
|
message_thread_id: input.messageThreadId,
|
|
@@ -586,7 +577,7 @@ async function sendMediaGroup(input, ctx) {
|
|
|
586
577
|
return { messages: asArray(result).map((message) => normalizeMessage(asRecord(message))) };
|
|
587
578
|
}
|
|
588
579
|
async function sendStructuredMessage(ctx, method, fields, input) {
|
|
589
|
-
const result = await request(ctx, method,
|
|
580
|
+
const result = await request(ctx, method, compactDefined({
|
|
590
581
|
business_connection_id: input.businessConnectionId,
|
|
591
582
|
chat_id: input.chatId,
|
|
592
583
|
message_thread_id: input.messageThreadId,
|
|
@@ -640,7 +631,7 @@ function deleteBusinessMessages(input, ctx) {
|
|
|
640
631
|
}
|
|
641
632
|
async function editMessageText(input, ctx) {
|
|
642
633
|
assertEditMessageTarget(input);
|
|
643
|
-
const result = await request(ctx, "editMessageText",
|
|
634
|
+
const result = await request(ctx, "editMessageText", compactDefined({
|
|
644
635
|
chat_id: input.chatId,
|
|
645
636
|
message_id: input.messageId,
|
|
646
637
|
inline_message_id: input.inlineMessageId,
|
|
@@ -649,12 +640,12 @@ async function editMessageText(input, ctx) {
|
|
|
649
640
|
link_preview_options: input.disableWebPagePreview === true ? { is_disabled: true } : void 0
|
|
650
641
|
}));
|
|
651
642
|
if (result === true) {
|
|
652
|
-
return { edited: true, message: null, inlineMessageId:
|
|
643
|
+
return { edited: true, message: null, inlineMessageId: trimmedText(input.inlineMessageId) ?? null };
|
|
653
644
|
}
|
|
654
645
|
return { edited: true, message: normalizeMessage(asRecord(result)), inlineMessageId: null };
|
|
655
646
|
}
|
|
656
647
|
async function sendPhoto(input, ctx) {
|
|
657
|
-
const result = await request(ctx, "sendPhoto",
|
|
648
|
+
const result = await request(ctx, "sendPhoto", compactDefined({
|
|
658
649
|
chat_id: input.chatId,
|
|
659
650
|
photo: urlOrFileId(input.photo),
|
|
660
651
|
caption: input.caption,
|
|
@@ -667,7 +658,7 @@ async function sendPhoto(input, ctx) {
|
|
|
667
658
|
return normalizeMessage(asRecord(result));
|
|
668
659
|
}
|
|
669
660
|
async function sendDocument(input, ctx) {
|
|
670
|
-
const result = await request(ctx, "sendDocument",
|
|
661
|
+
const result = await request(ctx, "sendDocument", compactDefined({
|
|
671
662
|
chat_id: input.chatId,
|
|
672
663
|
document: urlOrFileId(input.document),
|
|
673
664
|
caption: input.caption,
|
|
@@ -687,7 +678,7 @@ async function sendPoll(input, ctx) {
|
|
|
687
678
|
if (input.type === "quiz" && input.correctOptionId == null) {
|
|
688
679
|
throw new TBError("invalid_argument", "send_poll quiz polls require correctOptionId");
|
|
689
680
|
}
|
|
690
|
-
const result = await request(ctx, "sendPoll",
|
|
681
|
+
const result = await request(ctx, "sendPoll", compactDefined({
|
|
691
682
|
chat_id: input.chatId,
|
|
692
683
|
question: input.question,
|
|
693
684
|
options: input.options,
|
|
@@ -719,14 +710,14 @@ async function getChatAdministrators(input, ctx) {
|
|
|
719
710
|
}
|
|
720
711
|
async function getChatMembersCount(input, ctx) {
|
|
721
712
|
const result = await request(ctx, "getChatMemberCount", { chat_id: input.chatId });
|
|
722
|
-
const count =
|
|
713
|
+
const count = finiteNumber(result);
|
|
723
714
|
if (count === void 0) {
|
|
724
715
|
throw new TBError("unavailable", "Telegram \u7684\u6210\u5458\u6570\u4E0D\u662F\u4E00\u4E2A\u6570\u5B57", { retryable: true });
|
|
725
716
|
}
|
|
726
717
|
return { memberCount: count };
|
|
727
718
|
}
|
|
728
719
|
function banChatMember(input, ctx) {
|
|
729
|
-
return booleanAction(ctx, "banChatMember",
|
|
720
|
+
return booleanAction(ctx, "banChatMember", compactDefined({
|
|
730
721
|
chat_id: input.chatId,
|
|
731
722
|
user_id: input.userId,
|
|
732
723
|
until_date: input.untilDate,
|
|
@@ -734,14 +725,14 @@ function banChatMember(input, ctx) {
|
|
|
734
725
|
}));
|
|
735
726
|
}
|
|
736
727
|
function unbanChatMember(input, ctx) {
|
|
737
|
-
return booleanAction(ctx, "unbanChatMember",
|
|
728
|
+
return booleanAction(ctx, "unbanChatMember", compactDefined({
|
|
738
729
|
chat_id: input.chatId,
|
|
739
730
|
user_id: input.userId,
|
|
740
731
|
only_if_banned: input.onlyIfBanned
|
|
741
732
|
}));
|
|
742
733
|
}
|
|
743
734
|
function restrictChatMember(input, ctx) {
|
|
744
|
-
return booleanAction(ctx, "restrictChatMember",
|
|
735
|
+
return booleanAction(ctx, "restrictChatMember", compactDefined({
|
|
745
736
|
chat_id: input.chatId,
|
|
746
737
|
user_id: input.userId,
|
|
747
738
|
permissions: normalizeChatPermissions(input.permissions),
|
|
@@ -750,7 +741,7 @@ function restrictChatMember(input, ctx) {
|
|
|
750
741
|
}));
|
|
751
742
|
}
|
|
752
743
|
function promoteChatMember(input, ctx) {
|
|
753
|
-
return booleanAction(ctx, "promoteChatMember",
|
|
744
|
+
return booleanAction(ctx, "promoteChatMember", compactDefined({
|
|
754
745
|
chat_id: input.chatId,
|
|
755
746
|
user_id: input.userId,
|
|
756
747
|
is_anonymous: input.isAnonymous,
|
|
@@ -773,14 +764,14 @@ function promoteChatMember(input, ctx) {
|
|
|
773
764
|
}));
|
|
774
765
|
}
|
|
775
766
|
function setChatPermissions(input, ctx) {
|
|
776
|
-
return booleanAction(ctx, "setChatPermissions",
|
|
767
|
+
return booleanAction(ctx, "setChatPermissions", compactDefined({
|
|
777
768
|
chat_id: input.chatId,
|
|
778
769
|
permissions: normalizeChatPermissions(input.permissions),
|
|
779
770
|
use_independent_chat_permissions: input.useIndependentChatPermissions
|
|
780
771
|
}));
|
|
781
772
|
}
|
|
782
773
|
function pinChatMessage(input, ctx) {
|
|
783
|
-
return booleanAction(ctx, "pinChatMessage",
|
|
774
|
+
return booleanAction(ctx, "pinChatMessage", compactDefined({
|
|
784
775
|
business_connection_id: input.businessConnectionId,
|
|
785
776
|
chat_id: input.chatId,
|
|
786
777
|
message_id: input.messageId,
|
|
@@ -788,7 +779,7 @@ function pinChatMessage(input, ctx) {
|
|
|
788
779
|
}));
|
|
789
780
|
}
|
|
790
781
|
function unpinChatMessage(input, ctx) {
|
|
791
|
-
return booleanAction(ctx, "unpinChatMessage",
|
|
782
|
+
return booleanAction(ctx, "unpinChatMessage", compactDefined({
|
|
792
783
|
business_connection_id: input.businessConnectionId,
|
|
793
784
|
chat_id: input.chatId,
|
|
794
785
|
message_id: input.messageId
|
|
@@ -807,7 +798,7 @@ function deleteMessage(input, ctx) {
|
|
|
807
798
|
return booleanAction(ctx, "deleteMessage", { chat_id: input.chatId, message_id: input.messageId });
|
|
808
799
|
}
|
|
809
800
|
async function forwardMessage(input, ctx) {
|
|
810
|
-
const result = await request(ctx, "forwardMessage",
|
|
801
|
+
const result = await request(ctx, "forwardMessage", compactDefined({
|
|
811
802
|
chat_id: input.chatId,
|
|
812
803
|
from_chat_id: input.fromChatId,
|
|
813
804
|
message_id: input.messageId,
|
|
@@ -816,7 +807,7 @@ async function forwardMessage(input, ctx) {
|
|
|
816
807
|
return normalizeMessage(asRecord(result));
|
|
817
808
|
}
|
|
818
809
|
async function sendLocation(input, ctx) {
|
|
819
|
-
const result = await request(ctx, "sendLocation",
|
|
810
|
+
const result = await request(ctx, "sendLocation", compactDefined({
|
|
820
811
|
chat_id: input.chatId,
|
|
821
812
|
latitude: input.latitude,
|
|
822
813
|
longitude: input.longitude,
|
|
@@ -842,7 +833,7 @@ async function mutateChatInviteLink(ctx, method, input) {
|
|
|
842
833
|
if (source.memberLimit != null && source.createsJoinRequest === true) {
|
|
843
834
|
throw new TBError("invalid_argument", "memberLimit cannot be combined with createsJoinRequest");
|
|
844
835
|
}
|
|
845
|
-
const result = await request(ctx, method,
|
|
836
|
+
const result = await request(ctx, method, compactDefined({
|
|
846
837
|
chat_id: input.chatId,
|
|
847
838
|
invite_link: source.inviteLink,
|
|
848
839
|
name: source.name,
|
|
@@ -862,7 +853,7 @@ function revokeChatInviteLink(input, ctx) {
|
|
|
862
853
|
return mutateChatInviteLink(ctx, "revokeChatInviteLink", input);
|
|
863
854
|
}
|
|
864
855
|
function answerCallbackQuery(input, ctx) {
|
|
865
|
-
return booleanAction(ctx, "answerCallbackQuery",
|
|
856
|
+
return booleanAction(ctx, "answerCallbackQuery", compactDefined({
|
|
866
857
|
callback_query_id: input.callbackQueryId,
|
|
867
858
|
text: input.text,
|
|
868
859
|
show_alert: input.showAlert,
|
|
@@ -871,14 +862,14 @@ function answerCallbackQuery(input, ctx) {
|
|
|
871
862
|
}));
|
|
872
863
|
}
|
|
873
864
|
function setMyCommands(input, ctx) {
|
|
874
|
-
return booleanAction(ctx, "setMyCommands",
|
|
865
|
+
return booleanAction(ctx, "setMyCommands", compactDefined({
|
|
875
866
|
commands: input.commands,
|
|
876
867
|
scope: jsonLike(input.scope),
|
|
877
868
|
language_code: input.languageCode
|
|
878
869
|
}));
|
|
879
870
|
}
|
|
880
871
|
function setWebhook(input, ctx) {
|
|
881
|
-
return booleanAction(ctx, "setWebhook",
|
|
872
|
+
return booleanAction(ctx, "setWebhook", compactDefined({
|
|
882
873
|
// Telegram 会主动回访这个地址,故它同样要过出站可达性判定(填内网地址等于让上游探我们的内网)。
|
|
883
874
|
url: publicUrl(input.url),
|
|
884
875
|
secret_token: input.secretToken,
|
|
@@ -888,7 +879,7 @@ function setWebhook(input, ctx) {
|
|
|
888
879
|
}));
|
|
889
880
|
}
|
|
890
881
|
function deleteWebhook(input, ctx) {
|
|
891
|
-
return booleanAction(ctx, "deleteWebhook",
|
|
882
|
+
return booleanAction(ctx, "deleteWebhook", compactDefined({ drop_pending_updates: input.dropPendingUpdates }));
|
|
892
883
|
}
|
|
893
884
|
|
|
894
885
|
// ../plugins/src/telegram/schema.ts
|