telegram-bot-api-nodejs 1.0.43 → 1.0.44
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/README.md +35 -0
- package/index.d.ts +1 -0
- package/index.js +3 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# telegram-bot-api-nodejs
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
npm install telegram-bot-api-nodejs
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
# Usage
|
|
11
|
+
|
|
12
|
+
## Send message
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { sendMessage } from "telegram-bot-api-nodejs"
|
|
16
|
+
|
|
17
|
+
const token = "12345:abcd..."
|
|
18
|
+
const message = await sendMessage(token, {
|
|
19
|
+
chat_id: 12345,
|
|
20
|
+
text: "Hello",
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Parse webhook updates
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { parseUpdate } from "telegram-bot-api-nodejs"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const update = await parseUpdate(ctx.request.body)
|
|
31
|
+
|
|
32
|
+
if (update.message) {
|
|
33
|
+
// ...
|
|
34
|
+
}
|
|
35
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -1109,6 +1109,7 @@ export declare function isNotEnoughRightsError(err: unknown): boolean;
|
|
|
1109
1109
|
export declare function isUpgradeToSupergroupChatError(err: unknown): boolean;
|
|
1110
1110
|
export declare function isTextMustBeNonEmptyError(err: unknown): boolean;
|
|
1111
1111
|
export declare function isTooManyRequestsError(err: unknown): boolean;
|
|
1112
|
+
export declare function isMessageTooLongError(err: unknown): boolean;
|
|
1112
1113
|
export declare function parseRetryAfterTime(err: unknown): number;
|
|
1113
1114
|
export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
|
|
1114
1115
|
export declare function resolveChatName(chat: any): string;
|
package/index.js
CHANGED
|
@@ -577,6 +577,9 @@ export function isTextMustBeNonEmptyError(err) {
|
|
|
577
577
|
export function isTooManyRequestsError(err) {
|
|
578
578
|
return err instanceof Error && err.message.includes("Too Many Requests: retry after");
|
|
579
579
|
}
|
|
580
|
+
export function isMessageTooLongError(err) {
|
|
581
|
+
return err instanceof Error && err.message.includes("message is too long");
|
|
582
|
+
}
|
|
580
583
|
export function parseRetryAfterTime(err) {
|
|
581
584
|
if (!(err instanceof Error)) {
|
|
582
585
|
throw new RangeError("`err` needs to be an Error");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "telegram-bot-api-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"description": "Telegram Bot API client for nodejs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"index.js",
|
|
13
13
|
"index.d.ts",
|
|
14
|
-
"currencies.json"
|
|
14
|
+
"currencies.json",
|
|
15
|
+
"README.md"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
18
|
"prepublishOnly": "npm run build",
|