@codebam/cf-workers-telegram-bot 3.46.0 → 3.47.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.
|
@@ -54,13 +54,13 @@ export default class TelegramApi extends BotApi {
|
|
|
54
54
|
executeCommand = async (update) => this._executeCommand(update, update.message?.text ?? "") ||
|
|
55
55
|
this.updates.default;
|
|
56
56
|
// trigger answerInlineQuery command of BotAPI
|
|
57
|
-
answerInlineQuery = async (inline_query_id, results, cache_time = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
57
|
+
answerInlineQuery = async (inline_query_id, results, cache_time = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/answerInlineQuery`), {
|
|
58
58
|
inline_query_id: inline_query_id.toString(),
|
|
59
59
|
results: JSON.stringify(results),
|
|
60
60
|
cache_time: cache_time.toString(),
|
|
61
61
|
}).href));
|
|
62
62
|
// trigger sendMessage command of BotAPI
|
|
63
|
-
sendMessage = async (chat_id, text, parse_mode = "", disable_web_page_preview = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
63
|
+
sendMessage = async (chat_id, text, parse_mode = "", disable_web_page_preview = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendMessage`), {
|
|
64
64
|
chat_id: chat_id.toString(),
|
|
65
65
|
text,
|
|
66
66
|
parse_mode: parse_mode,
|
|
@@ -69,14 +69,14 @@ export default class TelegramApi extends BotApi {
|
|
|
69
69
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
70
70
|
}).href));
|
|
71
71
|
// trigger forwardMessage command of BotAPI
|
|
72
|
-
forwardMessage = async (chat_id, from_chat_id, disable_notification = false, message_id) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
72
|
+
forwardMessage = async (chat_id, from_chat_id, disable_notification = false, message_id) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendMessage`), {
|
|
73
73
|
chat_id: chat_id.toString(),
|
|
74
74
|
from_chat_id: from_chat_id.toString(),
|
|
75
75
|
message_id: message_id.toString(),
|
|
76
76
|
disable_notification: disable_notification.toString(),
|
|
77
77
|
}).href));
|
|
78
78
|
// trigger sendPhoto command of BotAPI
|
|
79
|
-
sendPhoto = async (chat_id, photo, caption = "", parse_mode = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
79
|
+
sendPhoto = async (chat_id, photo, caption = "", parse_mode = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendPhoto`), {
|
|
80
80
|
chat_id: chat_id.toString(),
|
|
81
81
|
photo,
|
|
82
82
|
caption,
|
|
@@ -85,7 +85,7 @@ export default class TelegramApi extends BotApi {
|
|
|
85
85
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
86
86
|
}).href));
|
|
87
87
|
// trigger sendVideo command of BotAPI
|
|
88
|
-
sendVideo = async (chat_id, video, duration = 0, width = 0, height = 0, thumb = "", caption = "", parse_mode = "", supports_streaming = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
88
|
+
sendVideo = async (chat_id, video, duration = 0, width = 0, height = 0, thumb = "", caption = "", parse_mode = "", supports_streaming = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendVideo`), {
|
|
89
89
|
chat_id: chat_id.toString(),
|
|
90
90
|
video: JSON.stringify(video),
|
|
91
91
|
duration: duration.toString(),
|
|
@@ -99,7 +99,7 @@ export default class TelegramApi extends BotApi {
|
|
|
99
99
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
100
100
|
}).href));
|
|
101
101
|
// trigger sendAnimation command of BotAPI
|
|
102
|
-
sendAnimation = async (chat_id, animation, duration = 0, width = 0, height = 0, thumb = "", caption = "", parse_mode = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
102
|
+
sendAnimation = async (chat_id, animation, duration = 0, width = 0, height = 0, thumb = "", caption = "", parse_mode = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendAnimation`), {
|
|
103
103
|
chat_id: chat_id.toString(),
|
|
104
104
|
animation: JSON.stringify(animation),
|
|
105
105
|
duration: duration.toString(),
|
|
@@ -112,7 +112,7 @@ export default class TelegramApi extends BotApi {
|
|
|
112
112
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
113
113
|
}).href));
|
|
114
114
|
// trigger sendLocation command of BotAPI
|
|
115
|
-
sendLocation = async (chat_id, latitude, longitude, live_period = 0, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
115
|
+
sendLocation = async (chat_id, latitude, longitude, live_period = 0, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendLocation`), {
|
|
116
116
|
chat_id: chat_id.toString(),
|
|
117
117
|
latitude: latitude.toString(),
|
|
118
118
|
longitude: longitude.toString(),
|
|
@@ -121,7 +121,7 @@ export default class TelegramApi extends BotApi {
|
|
|
121
121
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
122
122
|
}).href));
|
|
123
123
|
// trigger senPoll command of BotAPI
|
|
124
|
-
sendPoll = async (chat_id, question, options, is_anonymous = false, type = "", allows_multiple_answers = false, correct_option_id = 0, explanation = "", explanation_parse_mode = "", open_period = 0, close_date = 0, is_closed = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
124
|
+
sendPoll = async (chat_id, question, options, is_anonymous = false, type = "", allows_multiple_answers = false, correct_option_id = 0, explanation = "", explanation_parse_mode = "", open_period = 0, close_date = 0, is_closed = false, disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendPoll`), {
|
|
125
125
|
chat_id: chat_id.toString(),
|
|
126
126
|
question,
|
|
127
127
|
options: options.toString(),
|
|
@@ -138,14 +138,14 @@ export default class TelegramApi extends BotApi {
|
|
|
138
138
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
139
139
|
}).href));
|
|
140
140
|
// trigger senDice command of BotAPI
|
|
141
|
-
sendDice = async (chat_id, emoji = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
141
|
+
sendDice = async (chat_id, emoji = "", disable_notification = false, reply_to_message_id = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/sendDice`), {
|
|
142
142
|
chat_id: chat_id.toString(),
|
|
143
143
|
emoji,
|
|
144
144
|
disable_notification: disable_notification.toString(),
|
|
145
145
|
reply_to_message_id: reply_to_message_id.toString(),
|
|
146
146
|
}).href));
|
|
147
147
|
// bot api command to get user profile photos
|
|
148
|
-
getUserProfilePhotos = async (user_id, offset = 0, limit = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.
|
|
148
|
+
getUserProfilePhotos = async (user_id, offset = 0, limit = 0) => fetch(log(addSearchParams(new URL(`${this.webhook.api.origin}${this.webhook.api.pathname}/getUserProfilePhotos`), {
|
|
149
149
|
user_id: user_id.toString(),
|
|
150
150
|
offset: offset.toString(),
|
|
151
151
|
limit: limit.toString(),
|
|
@@ -4,15 +4,15 @@ export default class TelegramWebhook extends Webhook {
|
|
|
4
4
|
constructor(api, token, url) {
|
|
5
5
|
super(api, token, url);
|
|
6
6
|
}
|
|
7
|
-
set = async (drop_pending_updates = true) => sha256(this.token).then((access_key) => fetch_json(addSearchParams(new URL(`${this.api.origin}/setWebhook`), {
|
|
7
|
+
set = async (drop_pending_updates = true) => sha256(this.token).then((access_key) => fetch_json(addSearchParams(new URL(`${this.api.origin}${this.api.pathname}/setWebhook`), {
|
|
8
8
|
url: new URL(`${this.url.origin}${this.url.pathname}${access_key}`)
|
|
9
9
|
.href,
|
|
10
10
|
max_connections: "100",
|
|
11
11
|
allowed_updates: JSON.stringify(["message", "inline_query"]),
|
|
12
12
|
drop_pending_updates: drop_pending_updates.toString(),
|
|
13
13
|
})));
|
|
14
|
-
get = async () => fetch_json(new URL(`${this.api.
|
|
15
|
-
delete = async () => fetch_json(new URL(`${this.api.
|
|
14
|
+
get = async () => fetch_json(new URL(`${this.api.origin}${this.api.pathname}/getWebhookInfo`));
|
|
15
|
+
delete = async () => fetch_json(new URL(`${this.api.origin}${this.api.pathname}/deleteWebhook`));
|
|
16
16
|
commands = {
|
|
17
17
|
...this.commands,
|
|
18
18
|
set: this.set,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebam/cf-workers-telegram-bot",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.47.0",
|
|
4
4
|
"description": "serverless telegram bot on cf workers",
|
|
5
5
|
"main": "./dist/main/src/main.js",
|
|
6
6
|
"module": "./dist/main/src/main.js",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"prettier": "^2.8.4",
|
|
40
40
|
"typescript": "^4.9.5"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "05279fb873fc0f45050e2d0490e46b9c44a0eb2e"
|
|
43
43
|
}
|