telegram-bot-api-nodejs 1.0.70 → 1.0.72
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/index.d.ts +13 -6
- package/index.js +14 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -233,6 +233,17 @@ export interface GeneralForumTopicHidden {
|
|
|
233
233
|
}
|
|
234
234
|
export interface GeneralForumTopicUnhidden {
|
|
235
235
|
}
|
|
236
|
+
export interface Giveaway {
|
|
237
|
+
chats: Chat[];
|
|
238
|
+
winners_selection_date: number;
|
|
239
|
+
winner_count: number;
|
|
240
|
+
only_new_members?: true;
|
|
241
|
+
has_public_winners?: true;
|
|
242
|
+
prize_description?: string;
|
|
243
|
+
country_codes?: string[];
|
|
244
|
+
prize_star_count?: number;
|
|
245
|
+
premium_subscription_month_count?: number;
|
|
246
|
+
}
|
|
236
247
|
export interface VideoChatScheduled {
|
|
237
248
|
start_date: number;
|
|
238
249
|
}
|
|
@@ -256,12 +267,6 @@ export interface Message {
|
|
|
256
267
|
business_connection_id?: string;
|
|
257
268
|
chat: Chat;
|
|
258
269
|
via_bot?: User;
|
|
259
|
-
forward_from?: User;
|
|
260
|
-
forward_from_chat?: Chat;
|
|
261
|
-
forward_from_message_id?: number;
|
|
262
|
-
forward_signature?: string;
|
|
263
|
-
forward_sender_name?: string;
|
|
264
|
-
forward_date?: number;
|
|
265
270
|
forward_origin?: MessageOrigin;
|
|
266
271
|
is_topic_message?: boolean;
|
|
267
272
|
is_automatic_forward?: boolean;
|
|
@@ -315,6 +320,7 @@ export interface Message {
|
|
|
315
320
|
forum_topic_reopened?: ForumTopicReopened;
|
|
316
321
|
general_forum_topic_hidden?: GeneralForumTopicHidden;
|
|
317
322
|
general_forum_topic_unhidden?: GeneralForumTopicUnhidden;
|
|
323
|
+
giveaway?: Giveaway;
|
|
318
324
|
video_chat_scheduled?: VideoChatScheduled;
|
|
319
325
|
video_chat_started?: VideoChatStarted;
|
|
320
326
|
video_chat_ended?: VideoChatEnded;
|
|
@@ -1131,6 +1137,7 @@ export declare function isInvalidFileUrlSpecifiedError(err: unknown): boolean;
|
|
|
1131
1137
|
export declare function parseRetryAfterTime(err: unknown): number;
|
|
1132
1138
|
export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
|
|
1133
1139
|
export declare function resolveChatName(chat: any): string;
|
|
1140
|
+
export declare function resolveMessageOriginName(messageOrigin: MessageOrigin): string | undefined;
|
|
1134
1141
|
export declare function removeTokenFromUrl(url: string): string;
|
|
1135
1142
|
export declare namespace currencies {
|
|
1136
1143
|
interface Currency {
|
package/index.js
CHANGED
|
@@ -239,9 +239,6 @@ function parseMessage(m) {
|
|
|
239
239
|
...m,
|
|
240
240
|
from: m.from ? parseUser(m.from) : void 0,
|
|
241
241
|
chat: parseChat(m.chat),
|
|
242
|
-
forward_from: m.forward_from ? parseUser(m.forward_from) : void 0, // User;
|
|
243
|
-
forward_from_chat: m.forward_from_chat ? parseChat(m.forward_from_chat) : void 0, // Chat;
|
|
244
|
-
forward_date: m.forward_date ? Number(m.forward_date) : void 0, // number;
|
|
245
242
|
reply_to_message: m.reply_to_message ? parseMessage(m.reply_to_message) : void 0,
|
|
246
243
|
entities: m.entities ? parseEntities(m.entities) : void 0, // MessageEntity[];
|
|
247
244
|
audio: m.audio ? parseAudio(m.audio) : void 0,
|
|
@@ -660,6 +657,20 @@ export function resolveChatName(chat) {
|
|
|
660
657
|
`${chat.title}`.trim() ||
|
|
661
658
|
`@${chat.username || ""}`.trim();
|
|
662
659
|
}
|
|
660
|
+
export function resolveMessageOriginName(messageOrigin) {
|
|
661
|
+
if (messageOrigin.type === "channel") {
|
|
662
|
+
return resolveChatName(messageOrigin.chat);
|
|
663
|
+
}
|
|
664
|
+
if (messageOrigin.type === "user") {
|
|
665
|
+
return resolveChatName(messageOrigin.sender_user);
|
|
666
|
+
}
|
|
667
|
+
if (messageOrigin.type === "chat") {
|
|
668
|
+
return resolveChatName(messageOrigin.sender_chat);
|
|
669
|
+
}
|
|
670
|
+
if (messageOrigin.type === "hidden_user") {
|
|
671
|
+
return messageOrigin.sender_user_name || "Hidden User";
|
|
672
|
+
}
|
|
673
|
+
}
|
|
663
674
|
export function removeTokenFromUrl(url) {
|
|
664
675
|
return String(url).replace(/bot([\d]+)\:([^\/]+)/ig, function (match, botId, token) {
|
|
665
676
|
return `bot${botId}:${"*".repeat(token.length)}`;
|