telegram-bot-api-nodejs 1.0.42 → 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 +7 -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
|
@@ -208,6 +208,11 @@ export interface Chat {
|
|
|
208
208
|
can_set_sticker_set?: boolean;
|
|
209
209
|
sticker_set_name?: string;
|
|
210
210
|
}
|
|
211
|
+
export interface WriteAccessAllowed {
|
|
212
|
+
from_request?: boolean;
|
|
213
|
+
web_app_name?: string;
|
|
214
|
+
from_attachment_menu?: boolean;
|
|
215
|
+
}
|
|
211
216
|
export interface ChatBoostAdded {
|
|
212
217
|
boost_count: number;
|
|
213
218
|
}
|
|
@@ -302,6 +307,7 @@ export interface Message {
|
|
|
302
307
|
passport_data?: PassportData;
|
|
303
308
|
reply_markup?: InlineKeyboardMarkup;
|
|
304
309
|
sender_chat?: Chat;
|
|
310
|
+
write_access_allowed: WriteAccessAllowed;
|
|
305
311
|
boost_added?: ChatBoostAdded;
|
|
306
312
|
forum_topic_created?: ForumTopicCreated;
|
|
307
313
|
forum_topic_edited?: ForumTopicEdited;
|
|
@@ -1103,6 +1109,7 @@ export declare function isNotEnoughRightsError(err: unknown): boolean;
|
|
|
1103
1109
|
export declare function isUpgradeToSupergroupChatError(err: unknown): boolean;
|
|
1104
1110
|
export declare function isTextMustBeNonEmptyError(err: unknown): boolean;
|
|
1105
1111
|
export declare function isTooManyRequestsError(err: unknown): boolean;
|
|
1112
|
+
export declare function isMessageTooLongError(err: unknown): boolean;
|
|
1106
1113
|
export declare function parseRetryAfterTime(err: unknown): number;
|
|
1107
1114
|
export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
|
|
1108
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",
|