telegram-bot-api-nodejs
Advanced tools
Comparing version 1.0.36 to 1.0.38
@@ -1,2 +0,1 @@ | ||
export { formatPrice } from "./currencies.js"; | ||
export type ChatType = "private" | "group" | "supergroup" | "channel"; | ||
@@ -802,1 +801,19 @@ export type ChatAction = "typing" | "upload_photo" | "record_video" | "upload_video" | "record_audio" | "upload_audio" | "upload_document" | "find_location" | "record_video_note" | "upload_video_note"; | ||
export declare function resolveChatName(chat: any): string; | ||
export declare namespace currencies { | ||
interface Currency { | ||
code: string; | ||
title: string; | ||
symbol: string; | ||
native: string; | ||
thousands_sep: string; | ||
decimal_sep: string; | ||
symbol_left: boolean; | ||
space_between: boolean; | ||
drop_zeros: boolean; | ||
exp: number; | ||
min_amount: string | number; | ||
max_amount: string | number; | ||
} | ||
function formatPrice(amount: number, code: string): string; | ||
} | ||
export {}; |
44
index.js
@@ -1,2 +0,2 @@ | ||
export { formatPrice } from "./currencies.js"; | ||
import { readFileSync } from "fs"; | ||
/** | ||
@@ -609,1 +609,43 @@ * Methods | ||
} | ||
export var currencies; | ||
(function (currencies_1) { | ||
const __dirname = import.meta.dirname; | ||
let currencies = null; | ||
function formatPrice(amount, code) { | ||
if (!currencies) { | ||
currencies = loadCurrencies(); | ||
} | ||
const currency = currencies[code]; | ||
let value = ""; | ||
if (currency) { | ||
if (currency.symbol_left && currency.native) { | ||
value += currency.native; | ||
if (currency.space_between) { | ||
value += " "; | ||
} | ||
} | ||
if (currency.exp > 0) { | ||
value += amount / (10 ** currency.exp); | ||
} | ||
else { | ||
value += `${amount}`; | ||
} | ||
if (!currency.symbol_left && currency.native) { | ||
if (currency.space_between) { | ||
value += " "; | ||
} | ||
value += currency.native; | ||
} | ||
} | ||
else { | ||
value = `${code} ${amount / 2}`; | ||
} | ||
return value; | ||
} | ||
currencies_1.formatPrice = formatPrice; | ||
function loadCurrencies() { | ||
return JSON.parse(readFileSync(`${__dirname}/currencies.json`, { | ||
encoding: "utf8" | ||
})); | ||
} | ||
})(currencies || (currencies = {})); |
{ | ||
"name": "telegram-bot-api-nodejs", | ||
"version": "1.0.36", | ||
"version": "1.0.38", | ||
"description": "Telegram Bot API client for nodejs", | ||
@@ -13,3 +13,4 @@ "type": "module", | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"currencies.json" | ||
], | ||
@@ -16,0 +17,0 @@ "scripts": { |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
67821
4
1469
2