@gramio/format
Advanced tools
| class FormattableString { | ||
| /** Text of FormattableString (auto covert to it if entities is unsupported)*/ | ||
| text; | ||
| /** Entities of FormattableString */ | ||
| entities; | ||
| /** Create new FormattableString */ | ||
| constructor(text, entities) { | ||
| this.text = text; | ||
| this.entities = entities; | ||
| } | ||
| /** Create new FormattableString */ | ||
| static from(text, entities) { | ||
| return new FormattableString(text, entities); | ||
| } | ||
| toString() { | ||
| return this.text; | ||
| } | ||
| toJSON() { | ||
| return this.text; | ||
| } | ||
| // ![INFO] - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#instanceof-narrowing-through-symbolhasinstance | ||
| static [Symbol.hasInstance](value) { | ||
| return !!value && typeof value === "object" && "text" in value && "entities" in value; | ||
| } | ||
| } | ||
| function getFormattable(str) { | ||
| if (str instanceof FormattableString) return str; | ||
| if (str == null || str === void 0) { | ||
| return new FormattableString("", []); | ||
| } | ||
| return new FormattableString(str.toString(), []); | ||
| } | ||
| const isFormattableString = (value) => FormattableString[Symbol.hasInstance](value); | ||
| const FormattableMap = { | ||
| sendMessage: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| copyMessage: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendLivePhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAudio: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendDocument: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideo: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAnimation: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVoice: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideoNote: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPaidMedia: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMediaGroup: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.media.length) | ||
| params.media = params.media.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendLocation: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVenue: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendContact: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPoll: (params) => { | ||
| if (isFormattableString(params.question)) { | ||
| params.question_entities = params.question.entities; | ||
| params.question = params.question.text; | ||
| } | ||
| if (isFormattableString(params.explanation)) { | ||
| params.explanation_entities = params.explanation.entities; | ||
| params.explanation = params.explanation.text; | ||
| } | ||
| if (params.explanation_media !== void 0 && "caption" in params.explanation_media && isFormattableString(params.explanation_media.caption)) { | ||
| params.explanation_media.caption_entities = params.explanation_media.caption.entities; | ||
| params.explanation_media.caption = params.explanation_media.caption.text; | ||
| } | ||
| if (isFormattableString(params.description)) { | ||
| params.description_entities = params.description.entities; | ||
| params.description = params.description.text; | ||
| } | ||
| if (params.media !== void 0 && "caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => x.media !== void 0 && "caption" in x.media && isFormattableString(x.media.caption) ? { | ||
| ...x, | ||
| media: { | ||
| ...x.media, | ||
| caption: x.media.caption.text, | ||
| caption_entities: x.media.caption.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendDice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMessageDraft: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerGuestQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGift: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| giftPremiumSubscription: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| postStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerWebAppQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| savePreparedInlineMessage: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageText: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageCaption: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageMedia: (params) => { | ||
| if ("caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendSticker: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerInlineQuery: (params) => { | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "input_message_content" in x && x.input_message_content !== void 0 && "message_text" in x.input_message_content && isFormattableString(x.input_message_content.message_text) ? { | ||
| ...x, | ||
| input_message_content: { | ||
| ...x.input_message_content, | ||
| message_text: x.input_message_content.message_text.text, | ||
| entities: x.input_message_content.message_text.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendInvoice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGame: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| } | ||
| }; | ||
| export { FormattableString as F, FormattableMap as a, getFormattable as g }; |
| 'use strict'; | ||
| class FormattableString { | ||
| /** Text of FormattableString (auto covert to it if entities is unsupported)*/ | ||
| text; | ||
| /** Entities of FormattableString */ | ||
| entities; | ||
| /** Create new FormattableString */ | ||
| constructor(text, entities) { | ||
| this.text = text; | ||
| this.entities = entities; | ||
| } | ||
| /** Create new FormattableString */ | ||
| static from(text, entities) { | ||
| return new FormattableString(text, entities); | ||
| } | ||
| toString() { | ||
| return this.text; | ||
| } | ||
| toJSON() { | ||
| return this.text; | ||
| } | ||
| // ![INFO] - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#instanceof-narrowing-through-symbolhasinstance | ||
| static [Symbol.hasInstance](value) { | ||
| return !!value && typeof value === "object" && "text" in value && "entities" in value; | ||
| } | ||
| } | ||
| function getFormattable(str) { | ||
| if (str instanceof FormattableString) return str; | ||
| if (str == null || str === void 0) { | ||
| return new FormattableString("", []); | ||
| } | ||
| return new FormattableString(str.toString(), []); | ||
| } | ||
| const isFormattableString = (value) => FormattableString[Symbol.hasInstance](value); | ||
| const FormattableMap = { | ||
| sendMessage: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| copyMessage: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendLivePhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAudio: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendDocument: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideo: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAnimation: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVoice: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideoNote: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPaidMedia: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMediaGroup: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.media.length) | ||
| params.media = params.media.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendLocation: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVenue: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendContact: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPoll: (params) => { | ||
| if (isFormattableString(params.question)) { | ||
| params.question_entities = params.question.entities; | ||
| params.question = params.question.text; | ||
| } | ||
| if (isFormattableString(params.explanation)) { | ||
| params.explanation_entities = params.explanation.entities; | ||
| params.explanation = params.explanation.text; | ||
| } | ||
| if (params.explanation_media !== void 0 && "caption" in params.explanation_media && isFormattableString(params.explanation_media.caption)) { | ||
| params.explanation_media.caption_entities = params.explanation_media.caption.entities; | ||
| params.explanation_media.caption = params.explanation_media.caption.text; | ||
| } | ||
| if (isFormattableString(params.description)) { | ||
| params.description_entities = params.description.entities; | ||
| params.description = params.description.text; | ||
| } | ||
| if (params.media !== void 0 && "caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => x.media !== void 0 && "caption" in x.media && isFormattableString(x.media.caption) ? { | ||
| ...x, | ||
| media: { | ||
| ...x.media, | ||
| caption: x.media.caption.text, | ||
| caption_entities: x.media.caption.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendDice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMessageDraft: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerGuestQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGift: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| giftPremiumSubscription: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| postStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerWebAppQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| savePreparedInlineMessage: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageText: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageCaption: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageMedia: (params) => { | ||
| if ("caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendSticker: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerInlineQuery: (params) => { | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "input_message_content" in x && x.input_message_content !== void 0 && "message_text" in x.input_message_content && isFormattableString(x.input_message_content.message_text) ? { | ||
| ...x, | ||
| input_message_content: { | ||
| ...x.input_message_content, | ||
| message_text: x.input_message_content.message_text.text, | ||
| entities: x.input_message_content.message_text.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendInvoice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGame: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| } | ||
| }; | ||
| exports.FormattableMap = FormattableMap; | ||
| exports.FormattableString = FormattableString; | ||
| exports.getFormattable = getFormattable; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
| var index = require('../index.cjs'); | ||
| require('../mutator-DnoFwAyW.cjs'); | ||
| require('../mutator-jFPy6-Nr.cjs'); | ||
@@ -8,0 +8,0 @@ const ELEMENT_NODE = 1; |
| import { parse } from 'node-html-parser'; | ||
| import { join, formatSaveIndents, bold, link, blockquote, pre, code, strikethrough, underline, italic, format } from '../index.js'; | ||
| import '../mutator-CK5h8wA4.js'; | ||
| import '../mutator-DejDGTcy.js'; | ||
@@ -5,0 +5,0 @@ const ELEMENT_NODE = 1; |
+1
-1
| 'use strict'; | ||
| var mutator = require('./mutator-DnoFwAyW.cjs'); | ||
| var mutator = require('./mutator-jFPy6-Nr.cjs'); | ||
@@ -5,0 +5,0 @@ function buildFormatter(type) { |
+1
-1
@@ -12,3 +12,3 @@ import { APIMethods, APIMethodParams, TelegramUser } from '@gramio/types'; | ||
| * | ||
| * @codegenerated from Telegram Bot API 9.6 | ||
| * @codegenerated from Telegram Bot API 10.0 | ||
| */ | ||
@@ -15,0 +15,0 @@ declare const FormattableMap: FormattableMethods; |
+1
-1
@@ -12,3 +12,3 @@ import { APIMethods, APIMethodParams, TelegramUser } from '@gramio/types'; | ||
| * | ||
| * @codegenerated from Telegram Bot API 9.6 | ||
| * @codegenerated from Telegram Bot API 10.0 | ||
| */ | ||
@@ -15,0 +15,0 @@ declare const FormattableMap: FormattableMethods; |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { F as FormattableString, g as getFormattable } from './mutator-CK5h8wA4.js'; | ||
| export { a as FormattableMap } from './mutator-CK5h8wA4.js'; | ||
| import { F as FormattableString, g as getFormattable } from './mutator-DejDGTcy.js'; | ||
| export { a as FormattableMap } from './mutator-DejDGTcy.js'; | ||
@@ -4,0 +4,0 @@ function buildFormatter(type) { |
@@ -5,3 +5,3 @@ 'use strict'; | ||
| var index = require('../index.cjs'); | ||
| require('../mutator-DnoFwAyW.cjs'); | ||
| require('../mutator-jFPy6-Nr.cjs'); | ||
@@ -8,0 +8,0 @@ function processToken(token) { |
| import { lexer } from 'marked'; | ||
| import { join, blockquote, bold, italic, link, strikethrough, code, pre, formatSaveIndents, format } from '../index.js'; | ||
| import '../mutator-CK5h8wA4.js'; | ||
| import '../mutator-DejDGTcy.js'; | ||
@@ -5,0 +5,0 @@ function processToken(token) { |
| 'use strict'; | ||
| var mutator = require('./mutator-DnoFwAyW.cjs'); | ||
| var mutator = require('./mutator-jFPy6-Nr.cjs'); | ||
@@ -5,0 +5,0 @@ const formatMiddleware = (context, next) => { |
@@ -1,2 +0,2 @@ | ||
| import { a as FormattableMap } from './mutator-CK5h8wA4.js'; | ||
| import { a as FormattableMap } from './mutator-DejDGTcy.js'; | ||
@@ -3,0 +3,0 @@ const formatMiddleware = (context, next) => { |
+7
-7
| { | ||
| "name": "@gramio/format", | ||
| "version": "0.7.0", | ||
| "version": "0.8.0", | ||
| "repository": { | ||
@@ -10,13 +10,13 @@ "type": "git", | ||
| "dependencies": { | ||
| "@gramio/types": "^9.6.0" | ||
| "@gramio/types": "^10.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.4.4", | ||
| "@biomejs/biome": "^2.4.14", | ||
| "@gramio/schema-parser": "^1.1.0", | ||
| "@types/bun": "^1.3.9", | ||
| "@types/bun": "^1.3.13", | ||
| "expect-type": "^1.3.0", | ||
| "marked": "^17.0.3", | ||
| "node-html-parser": "^7.0.2", | ||
| "marked": "^17.0.6", | ||
| "node-html-parser": "^7.1.0", | ||
| "pkgroll": "^2.27.0", | ||
| "prettier": "^3.8.1", | ||
| "prettier": "^3.8.3", | ||
| "typescript": "^5.9.3" | ||
@@ -23,0 +23,0 @@ }, |
| class FormattableString { | ||
| /** Text of FormattableString (auto covert to it if entities is unsupported)*/ | ||
| text; | ||
| /** Entities of FormattableString */ | ||
| entities; | ||
| /** Create new FormattableString */ | ||
| constructor(text, entities) { | ||
| this.text = text; | ||
| this.entities = entities; | ||
| } | ||
| /** Create new FormattableString */ | ||
| static from(text, entities) { | ||
| return new FormattableString(text, entities); | ||
| } | ||
| toString() { | ||
| return this.text; | ||
| } | ||
| toJSON() { | ||
| return this.text; | ||
| } | ||
| // ![INFO] - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#instanceof-narrowing-through-symbolhasinstance | ||
| static [Symbol.hasInstance](value) { | ||
| return !!value && typeof value === "object" && "text" in value && "entities" in value; | ||
| } | ||
| } | ||
| function getFormattable(str) { | ||
| if (str instanceof FormattableString) return str; | ||
| if (str == null || str === void 0) { | ||
| return new FormattableString("", []); | ||
| } | ||
| return new FormattableString(str.toString(), []); | ||
| } | ||
| const isFormattableString = (value) => FormattableString[Symbol.hasInstance](value); | ||
| const FormattableMap = { | ||
| sendMessage: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| copyMessage: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAudio: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendDocument: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideo: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAnimation: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVoice: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideoNote: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPaidMedia: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMediaGroup: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.media.length) | ||
| params.media = params.media.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendLocation: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVenue: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendContact: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPoll: (params) => { | ||
| if (isFormattableString(params.question)) { | ||
| params.question_entities = params.question.entities; | ||
| params.question = params.question.text; | ||
| } | ||
| if (isFormattableString(params.explanation)) { | ||
| params.explanation_entities = params.explanation.entities; | ||
| params.explanation = params.explanation.text; | ||
| } | ||
| if (isFormattableString(params.description)) { | ||
| params.description_entities = params.description.entities; | ||
| params.description = params.description.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendDice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMessageDraft: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGift: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| giftPremiumSubscription: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| postStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerWebAppQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| savePreparedInlineMessage: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageText: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageCaption: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageMedia: (params) => { | ||
| if ("caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendSticker: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerInlineQuery: (params) => { | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "input_message_content" in x && x.input_message_content !== void 0 && "message_text" in x.input_message_content && isFormattableString(x.input_message_content.message_text) ? { | ||
| ...x, | ||
| input_message_content: { | ||
| ...x.input_message_content, | ||
| message_text: x.input_message_content.message_text.text, | ||
| entities: x.input_message_content.message_text.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendInvoice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGame: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| } | ||
| }; | ||
| export { FormattableString as F, FormattableMap as a, getFormattable as g }; |
| 'use strict'; | ||
| class FormattableString { | ||
| /** Text of FormattableString (auto covert to it if entities is unsupported)*/ | ||
| text; | ||
| /** Entities of FormattableString */ | ||
| entities; | ||
| /** Create new FormattableString */ | ||
| constructor(text, entities) { | ||
| this.text = text; | ||
| this.entities = entities; | ||
| } | ||
| /** Create new FormattableString */ | ||
| static from(text, entities) { | ||
| return new FormattableString(text, entities); | ||
| } | ||
| toString() { | ||
| return this.text; | ||
| } | ||
| toJSON() { | ||
| return this.text; | ||
| } | ||
| // ![INFO] - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#instanceof-narrowing-through-symbolhasinstance | ||
| static [Symbol.hasInstance](value) { | ||
| return !!value && typeof value === "object" && "text" in value && "entities" in value; | ||
| } | ||
| } | ||
| function getFormattable(str) { | ||
| if (str instanceof FormattableString) return str; | ||
| if (str == null || str === void 0) { | ||
| return new FormattableString("", []); | ||
| } | ||
| return new FormattableString(str.toString(), []); | ||
| } | ||
| const isFormattableString = (value) => FormattableString[Symbol.hasInstance](value); | ||
| const FormattableMap = { | ||
| sendMessage: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| copyMessage: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPhoto: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAudio: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendDocument: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideo: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendAnimation: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVoice: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVideoNote: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPaidMedia: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMediaGroup: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.media.length) | ||
| params.media = params.media.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendLocation: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendVenue: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendContact: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendPoll: (params) => { | ||
| if (isFormattableString(params.question)) { | ||
| params.question_entities = params.question.entities; | ||
| params.question = params.question.text; | ||
| } | ||
| if (isFormattableString(params.explanation)) { | ||
| params.explanation_entities = params.explanation.entities; | ||
| params.explanation = params.explanation.text; | ||
| } | ||
| if (isFormattableString(params.description)) { | ||
| params.description_entities = params.description.entities; | ||
| params.description = params.description.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.options.length) | ||
| params.options = params.options.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendDice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendMessageDraft: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGift: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| giftPremiumSubscription: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.text_entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| postStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editStory: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerWebAppQuery: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| savePreparedInlineMessage: (params) => { | ||
| if ("caption" in params.result && isFormattableString(params.result.caption)) { | ||
| params.result.caption_entities = params.result.caption.entities; | ||
| params.result.caption = params.result.caption.text; | ||
| } | ||
| if ("input_message_content" in params.result && params.result.input_message_content !== void 0 && "message_text" in params.result.input_message_content && isFormattableString( | ||
| params.result.input_message_content.message_text | ||
| )) { | ||
| params.result.input_message_content.entities = params.result.input_message_content.message_text.entities; | ||
| params.result.input_message_content.message_text = params.result.input_message_content.message_text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageText: (params) => { | ||
| if (isFormattableString(params.text)) { | ||
| params.entities = params.text.entities; | ||
| params.text = params.text.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageCaption: (params) => { | ||
| if (isFormattableString(params.caption)) { | ||
| params.caption_entities = params.caption.entities; | ||
| params.caption = params.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageMedia: (params) => { | ||
| if ("caption" in params.media && isFormattableString(params.media.caption)) { | ||
| params.media.caption_entities = params.media.caption.entities; | ||
| params.media.caption = params.media.caption.text; | ||
| } | ||
| return params; | ||
| }, | ||
| editMessageChecklist: (params) => { | ||
| if (isFormattableString(params.checklist.title)) { | ||
| params.checklist.title_entities = params.checklist.title.entities; | ||
| params.checklist.title = params.checklist.title.text; | ||
| } | ||
| if (params.checklist.tasks.length) | ||
| params.checklist.tasks = params.checklist.tasks.map( | ||
| (x) => "text" in x && isFormattableString(x.text) ? { | ||
| ...x, | ||
| text: x.text.text, | ||
| text_entities: x.text.entities | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendSticker: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| answerInlineQuery: (params) => { | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "caption" in x && isFormattableString(x.caption) ? { | ||
| ...x, | ||
| caption: x.caption.text, | ||
| caption_entities: x.caption.entities | ||
| } : x | ||
| ); | ||
| if (params.results.length) | ||
| params.results = params.results.map( | ||
| (x) => "input_message_content" in x && x.input_message_content !== void 0 && "message_text" in x.input_message_content && isFormattableString(x.input_message_content.message_text) ? { | ||
| ...x, | ||
| input_message_content: { | ||
| ...x.input_message_content, | ||
| message_text: x.input_message_content.message_text.text, | ||
| entities: x.input_message_content.message_text.entities | ||
| } | ||
| } : x | ||
| ); | ||
| return params; | ||
| }, | ||
| sendInvoice: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| }, | ||
| sendGame: (params) => { | ||
| if (params.reply_parameters !== void 0 && "quote" in params.reply_parameters && isFormattableString(params.reply_parameters.quote)) { | ||
| params.reply_parameters.quote_entities = params.reply_parameters.quote.entities; | ||
| params.reply_parameters.quote = params.reply_parameters.quote.text; | ||
| } | ||
| return params; | ||
| } | ||
| }; | ||
| exports.FormattableMap = FormattableMap; | ||
| exports.FormattableString = FormattableString; | ||
| exports.getFormattable = getFormattable; |
Sorry, the diff of this file is not supported yet
154348
2.93%1903
4.73%+ Added
- Removed
Updated