@codebam/cf-workers-telegram-bot 8.0.1 → 8.1.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
CHANGED
|
@@ -10,6 +10,11 @@ export default class TelegramApi {
|
|
|
10
10
|
* @param data - data to append to the request
|
|
11
11
|
*/
|
|
12
12
|
getApiUrl(botApi: string, slug: string, data: Record<string, number | string | boolean>): Request<unknown, CfProperties<unknown>>;
|
|
13
|
+
sendChatAction(botApi: string, data: {
|
|
14
|
+
business_connection_id?: string;
|
|
15
|
+
chat_id: number | string;
|
|
16
|
+
action: string;
|
|
17
|
+
}): Promise<Response>;
|
|
13
18
|
/**
|
|
14
19
|
* Get a file with a given file_id
|
|
15
20
|
* @param botApi - full URL to the telegram API without slug
|
package/dist/telegram_api.js
CHANGED
|
@@ -14,6 +14,11 @@ export default class TelegramApi {
|
|
|
14
14
|
}
|
|
15
15
|
return new Request(`${request.toString()}?${params.toString()}`);
|
|
16
16
|
}
|
|
17
|
+
async sendChatAction(botApi, data) {
|
|
18
|
+
const url = this.getApiUrl(botApi, 'sendChatAction', data);
|
|
19
|
+
const response = await fetch(url);
|
|
20
|
+
return response;
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
18
23
|
* Get a file with a given file_id
|
|
19
24
|
* @param botApi - full URL to the telegram API without slug
|
|
@@ -35,6 +35,7 @@ export default class TelegramExecutionContext {
|
|
|
35
35
|
* @param options - any additional options to pass to sendPhoto
|
|
36
36
|
*/
|
|
37
37
|
replyPhoto(photo: string, caption?: string, options?: Record<string, number | string | boolean>): Promise<Response | undefined>;
|
|
38
|
+
sendTyping(): Promise<Response | undefined>;
|
|
38
39
|
/**
|
|
39
40
|
* Reply to the last message with text
|
|
40
41
|
* @param message - text to reply with
|
|
@@ -103,6 +103,23 @@ export default class TelegramExecutionContext {
|
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
async sendTyping() {
|
|
107
|
+
switch (this.update_type) {
|
|
108
|
+
case 'message':
|
|
109
|
+
return await this.api.sendChatAction(this.bot.api.toString(), {
|
|
110
|
+
chat_id: this.update.message?.chat.id.toString() ?? '',
|
|
111
|
+
action: 'typing',
|
|
112
|
+
});
|
|
113
|
+
case 'business_message':
|
|
114
|
+
return await this.api.sendChatAction(this.bot.api.toString(), {
|
|
115
|
+
business_connection_id: this.update.business_message?.business_connection_id.toString(),
|
|
116
|
+
chat_id: this.update.business_message?.chat.id.toString() ?? '',
|
|
117
|
+
action: 'typing',
|
|
118
|
+
});
|
|
119
|
+
default:
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
106
123
|
/**
|
|
107
124
|
* Reply to the last message with text
|
|
108
125
|
* @param message - text to reply with
|