@codebam/cf-workers-telegram-bot 7.18.0 → 7.19.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/telegram_api.d.ts +1 -1
- package/dist/telegram_api.js +1 -2
- package/dist/telegram_bot.js +4 -0
- package/dist/telegram_execution_context.d.ts +1 -1
- package/dist/telegram_execution_context.js +11 -0
- package/dist/types/TelegramDocument.d.ts +9 -0
- package/dist/types/TelegramDocument.js +1 -0
- package/dist/types/TelegramMessage.d.ts +2 -0
- package/package.json +2 -2
package/dist/telegram_api.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default class TelegramApi {
|
|
|
7
7
|
getApiUrl(botApi: string, slug: string, data: Record<string, SerializableData>): Request<unknown, CfProperties<unknown>>;
|
|
8
8
|
getFile(botApi: string, data: {
|
|
9
9
|
file_id: string;
|
|
10
|
-
}, token: string): Promise<
|
|
10
|
+
}, token: string): Promise<Response>;
|
|
11
11
|
sendMessage(botApi: string, data: {
|
|
12
12
|
reply_to_message_id: number | string;
|
|
13
13
|
chat_id: number | string;
|
package/dist/telegram_api.js
CHANGED
|
@@ -12,8 +12,7 @@ export default class TelegramApi {
|
|
|
12
12
|
const response = await fetch(url);
|
|
13
13
|
const json = await response.json();
|
|
14
14
|
const file_path = json.result.file_path;
|
|
15
|
-
|
|
16
|
-
return await file_response.arrayBuffer();
|
|
15
|
+
return await fetch(`https://api.telegram.org/file/bot${token}/${file_path}`);
|
|
17
16
|
}
|
|
18
17
|
async sendMessage(botApi, data) {
|
|
19
18
|
const url = this.getApiUrl(botApi, 'sendMessage', data);
|
package/dist/telegram_bot.js
CHANGED
|
@@ -15,7 +15,7 @@ export default class TelegramExecutionContext {
|
|
|
15
15
|
setData(key: string, value: SerializableData): this;
|
|
16
16
|
getData(key: string): SerializableData;
|
|
17
17
|
replyVideo(video: string, options?: Record<string, SerializableData>): Promise<Response | undefined>;
|
|
18
|
-
getFile(file_id: string): Promise<
|
|
18
|
+
getFile(file_id: string): Promise<Response>;
|
|
19
19
|
replyPhoto(photo: string, caption?: string, options?: Record<string, SerializableData>): Promise<Response | undefined>;
|
|
20
20
|
reply(message: string, parse_mode?: string, options?: Record<string, SerializableData>): Promise<Response | undefined>;
|
|
21
21
|
}
|
|
@@ -20,6 +20,9 @@ export default class TelegramExecutionContext {
|
|
|
20
20
|
else if (this.update.inline_query?.query) {
|
|
21
21
|
this.update_type = 'inline';
|
|
22
22
|
}
|
|
23
|
+
else if (this.update.message?.document) {
|
|
24
|
+
this.update_type = 'document';
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
getText() {
|
|
25
28
|
return this.update.message?.text ?? this.update.inline_query?.query ?? '';
|
|
@@ -106,6 +109,14 @@ export default class TelegramExecutionContext {
|
|
|
106
109
|
inline_query_id: this.update.inline_query?.id.toString() ?? '',
|
|
107
110
|
results: [new TelegramInlineQueryResultArticle(message)],
|
|
108
111
|
});
|
|
112
|
+
case 'document':
|
|
113
|
+
return await this.api.sendMessage(this.bot.api.toString(), {
|
|
114
|
+
...options,
|
|
115
|
+
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
116
|
+
reply_to_message_id: this.update.message?.message_id.toString() ?? '',
|
|
117
|
+
text: message,
|
|
118
|
+
parse_mode,
|
|
119
|
+
});
|
|
109
120
|
default:
|
|
110
121
|
break;
|
|
111
122
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import TelegramChat from './TelegramChat.js';
|
|
2
|
+
import { TelegramDocument } from './TelegramDocument.js';
|
|
2
3
|
import TelegramFrom from './TelegramFrom.js';
|
|
3
4
|
import TelegramMessageEntity from './TelegramMessageEntity.js';
|
|
4
5
|
import TelegramPhotoSize from './TelegramPhotoSize.js';
|
|
@@ -24,6 +25,7 @@ interface TelegramMessage {
|
|
|
24
25
|
author_signature?: string;
|
|
25
26
|
text?: string;
|
|
26
27
|
entities?: TelegramMessageEntity[];
|
|
28
|
+
document?: TelegramDocument;
|
|
27
29
|
photo?: TelegramPhotoSize[];
|
|
28
30
|
caption?: string;
|
|
29
31
|
caption_entities?: TelegramMessageEntity[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.19.0",
|
|
4
4
|
"description": "serverless telegram bot on cf workers",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"module": "./dist/main.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript-eslint": "^7.10.0",
|
|
45
45
|
"vitest": "^1.6.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "6a464429f3ce661593659db8145d5b73ac75e5e3"
|
|
48
48
|
}
|