@gramio/format
Advanced tools
+7
-0
@@ -408,2 +408,8 @@ 'use strict'; | ||
| ); | ||
| const dateTime = buildFormatterWithArgs( | ||
| "date_time", | ||
| // @ts-expect-error string key doesn't match number type in T | ||
| "unix_time", | ||
| "date_time_format" | ||
| ); | ||
| function join(array, iteratorOrSeparator, separator = ", ") { | ||
@@ -492,2 +498,3 @@ let text = ""; | ||
| exports.customEmoji = customEmoji; | ||
| exports.dateTime = dateTime; | ||
| exports.expandableBlockquote = expandableBlockquote; | ||
@@ -494,0 +501,0 @@ exports.format = format; |
+32
-1
@@ -180,5 +180,36 @@ import { APIMethods, APIMethodParams, TelegramUser } from '@gramio/types'; | ||
| * **NOTE**: Custom emoji entities can only be used by bots that purchased additional usernames on [Fragment](https://fragment.com/). | ||
| *  | ||
| */ | ||
| declare const customEmoji: (str: Stringable | null | undefined, custom_emoji_id: string) => FormattableString; | ||
| /** | ||
| * Format text as a date/time entity with a Unix timestamp. | ||
| * Telegram renders it in the user's locale and timezone. | ||
| * | ||
| * @param str - The display text (shown as-is when `date_time_format` is empty) | ||
| * @param unix_time - Unix timestamp associated with the entity | ||
| * @param date_time_format - Optional format string matching `r|w?[dD]?[tT]?`: | ||
| * - `""` — display text as-is; user can still see the date in their local format | ||
| * - `"r"` — relative time (e.g. "in 3 hours"). Cannot be combined with other chars. | ||
| * - `"w"` — day of week in user's language | ||
| * - `"d"` — short date (e.g. "17.03.22") | ||
| * - `"D"` — long date (e.g. "March 17, 2022") | ||
| * - `"t"` — short time (e.g. "22:45") | ||
| * - `"T"` — long time (e.g. "22:45:00") | ||
| * - Combinations: `"wD"`, `"dt"`, `"wDT"`, `"Dt"`, etc. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * dateTime("soon", 1740787200, "r") // relative: "in 2 days" | ||
| * dateTime("17.03.22", 1740787200, "d") // short date | ||
| * dateTime("March 17", 1740787200, "D") // long date | ||
| * dateTime("22:45", 1740787200, "t") // short time | ||
| * dateTime("22:45:00", 1740787200, "T") // long time | ||
| * dateTime("Thu, March 17", 1740787200, "wD") // weekday + long date | ||
| * dateTime("March 17, 22:45", 1740787200, "Dt") // long date + short time | ||
| * format`Event starts ${dateTime("March 17 at 22:45", 1740787200, "DT")}` | ||
| * ``` | ||
| *  | ||
| */ | ||
| declare const dateTime: (str: Stringable | null | undefined, unix_time: number, date_time_format?: string | undefined) => FormattableString; | ||
| /** | ||
| * Helper for great work with formattable arrays. ([].join break styling) | ||
@@ -247,2 +278,2 @@ * Separator by default is `, ` | ||
| export { FormattableMap, FormattableString, Stringable, blockquote, bold, code, customEmoji, expandableBlockquote, format, formatSaveIndents, italic, join, link, mention, pre, spoiler, strikethrough, underline }; | ||
| export { FormattableMap, FormattableString, Stringable, blockquote, bold, code, customEmoji, dateTime, expandableBlockquote, format, formatSaveIndents, italic, join, link, mention, pre, spoiler, strikethrough, underline }; |
+32
-1
@@ -180,5 +180,36 @@ import { APIMethods, APIMethodParams, TelegramUser } from '@gramio/types'; | ||
| * **NOTE**: Custom emoji entities can only be used by bots that purchased additional usernames on [Fragment](https://fragment.com/). | ||
| *  | ||
| */ | ||
| declare const customEmoji: (str: Stringable | null | undefined, custom_emoji_id: string) => FormattableString; | ||
| /** | ||
| * Format text as a date/time entity with a Unix timestamp. | ||
| * Telegram renders it in the user's locale and timezone. | ||
| * | ||
| * @param str - The display text (shown as-is when `date_time_format` is empty) | ||
| * @param unix_time - Unix timestamp associated with the entity | ||
| * @param date_time_format - Optional format string matching `r|w?[dD]?[tT]?`: | ||
| * - `""` — display text as-is; user can still see the date in their local format | ||
| * - `"r"` — relative time (e.g. "in 3 hours"). Cannot be combined with other chars. | ||
| * - `"w"` — day of week in user's language | ||
| * - `"d"` — short date (e.g. "17.03.22") | ||
| * - `"D"` — long date (e.g. "March 17, 2022") | ||
| * - `"t"` — short time (e.g. "22:45") | ||
| * - `"T"` — long time (e.g. "22:45:00") | ||
| * - Combinations: `"wD"`, `"dt"`, `"wDT"`, `"Dt"`, etc. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * dateTime("soon", 1740787200, "r") // relative: "in 2 days" | ||
| * dateTime("17.03.22", 1740787200, "d") // short date | ||
| * dateTime("March 17", 1740787200, "D") // long date | ||
| * dateTime("22:45", 1740787200, "t") // short time | ||
| * dateTime("22:45:00", 1740787200, "T") // long time | ||
| * dateTime("Thu, March 17", 1740787200, "wD") // weekday + long date | ||
| * dateTime("March 17, 22:45", 1740787200, "Dt") // long date + short time | ||
| * format`Event starts ${dateTime("March 17 at 22:45", 1740787200, "DT")}` | ||
| * ``` | ||
| *  | ||
| */ | ||
| declare const dateTime: (str: Stringable | null | undefined, unix_time: number, date_time_format?: string | undefined) => FormattableString; | ||
| /** | ||
| * Helper for great work with formattable arrays. ([].join break styling) | ||
@@ -247,2 +278,2 @@ * Separator by default is `, ` | ||
| export { FormattableMap, FormattableString, Stringable, blockquote, bold, code, customEmoji, expandableBlockquote, format, formatSaveIndents, italic, join, link, mention, pre, spoiler, strikethrough, underline }; | ||
| export { FormattableMap, FormattableString, Stringable, blockquote, bold, code, customEmoji, dateTime, expandableBlockquote, format, formatSaveIndents, italic, join, link, mention, pre, spoiler, strikethrough, underline }; |
+7
-1
@@ -406,2 +406,8 @@ class FormattableString { | ||
| ); | ||
| const dateTime = buildFormatterWithArgs( | ||
| "date_time", | ||
| // @ts-expect-error string key doesn't match number type in T | ||
| "unix_time", | ||
| "date_time_format" | ||
| ); | ||
| function join(array, iteratorOrSeparator, separator = ", ") { | ||
@@ -484,2 +490,2 @@ let text = ""; | ||
| export { FormattableMap, FormattableString, blockquote, bold, code, customEmoji, expandableBlockquote, format, formatSaveIndents, getFormattable, italic, join, link, mention, pre, spoiler, strikethrough, underline }; | ||
| export { FormattableMap, FormattableString, blockquote, bold, code, customEmoji, dateTime, expandableBlockquote, format, formatSaveIndents, getFormattable, italic, join, link, mention, pre, spoiler, strikethrough, underline }; |
+9
-9
| { | ||
| "name": "@gramio/format", | ||
| "version": "0.4.0", | ||
| "version": "0.5.0", | ||
| "repository": { | ||
@@ -10,13 +10,13 @@ "type": "git", | ||
| "dependencies": { | ||
| "@gramio/types": "^9.1.3" | ||
| "@gramio/types": "^9.5.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.1.1", | ||
| "@types/bun": "^1.2.18", | ||
| "expect-type": "^1.2.2", | ||
| "marked": "^16.0.0", | ||
| "@biomejs/biome": "^2.4.4", | ||
| "@types/bun": "^1.3.9", | ||
| "expect-type": "^1.3.0", | ||
| "marked": "^17.0.3", | ||
| "node-html-parser": "^7.0.2", | ||
| "pkgroll": "^2.14.1", | ||
| "prettier": "^3.6.2", | ||
| "typescript": "^5.8.3" | ||
| "pkgroll": "^2.27.0", | ||
| "prettier": "^3.8.1", | ||
| "typescript": "^5.9.3" | ||
| }, | ||
@@ -23,0 +23,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
144901
2.61%1710
2.64%Updated