telegram-bot-api-nodejs 1.0.71 → 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.
Files changed (3) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +14 -0
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1137,6 +1137,7 @@ export declare function isInvalidFileUrlSpecifiedError(err: unknown): boolean;
1137
1137
  export declare function parseRetryAfterTime(err: unknown): number;
1138
1138
  export declare function resolveNameFromMessageOrigin(messageOrigin: MessageOrigin): string;
1139
1139
  export declare function resolveChatName(chat: any): string;
1140
+ export declare function resolveMessageOriginName(messageOrigin: MessageOrigin): string | undefined;
1140
1141
  export declare function removeTokenFromUrl(url: string): string;
1141
1142
  export declare namespace currencies {
1142
1143
  interface Currency {
package/index.js CHANGED
@@ -657,6 +657,20 @@ export function resolveChatName(chat) {
657
657
  `${chat.title}`.trim() ||
658
658
  `@${chat.username || ""}`.trim();
659
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
+ }
660
674
  export function removeTokenFromUrl(url) {
661
675
  return String(url).replace(/bot([\d]+)\:([^\/]+)/ig, function (match, botId, token) {
662
676
  return `bot${botId}:${"*".repeat(token.length)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telegram-bot-api-nodejs",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "Telegram Bot API client for nodejs",
5
5
  "type": "module",
6
6
  "main": "index.js",