@grammyjs/parse-mode
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -20,3 +20,4 @@ import type { MessageEntity } from "./deps.node.js"; | ||
declare const mentionUser: (stringLike: Stringable, userId: number) => FormattedString; | ||
declare const linkMessage: (stringLike: Stringable, chatId: number, messageId: number) => Stringable; | ||
declare const fmt: (rawStringParts: TemplateStringsArray | string[], ...stringLikes: Stringable[]) => FormattedString; | ||
export { bold, code, fmt, FormattedString, italic, link, mentionUser, pre, spoiler, strikethrough, underline, }; | ||
export { bold, code, fmt, FormattedString, italic, link, linkMessage, mentionUser, pre, spoiler, strikethrough, underline, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.underline = exports.strikethrough = exports.spoiler = exports.pre = exports.mentionUser = exports.link = exports.italic = exports.FormattedString = exports.fmt = exports.code = exports.bold = void 0; | ||
exports.underline = exports.strikethrough = exports.spoiler = exports.pre = exports.mentionUser = exports.linkMessage = exports.link = exports.italic = exports.FormattedString = exports.fmt = exports.code = exports.bold = void 0; | ||
class FormattedString { | ||
@@ -54,2 +54,16 @@ constructor(text, entities) { | ||
exports.mentionUser = mentionUser; | ||
const linkMessage = (stringLike, chatId, messageId) => { | ||
if (chatId > 0) { | ||
console.warn("linkMessage can only be used for supergroups and channel messages. Refusing to transform into link."); | ||
return stringLike; | ||
} | ||
else if (chatId < -1002147483647 || chatId > -1000000000000) { | ||
console.warn("linkMessage is not able to link messages whose chatIds are greater than -1000000000000 or less than -1002147483647 at this moment. Refusing to transform into link."); | ||
return stringLike; | ||
} | ||
else { | ||
return link(stringLike, `https://t.me/c/${(chatId + 1000000000000) * -1}/${messageId}`); | ||
} | ||
}; | ||
exports.linkMessage = linkMessage; | ||
// Root format function | ||
@@ -56,0 +70,0 @@ const fmt = (rawStringParts, ...stringLikes) => { |
{ | ||
"name": "@grammyjs/parse-mode", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Plugin for hydrating ctx with familiar reply variants and for setting default parse_mode", | ||
@@ -5,0 +5,0 @@ "author": "KnightNiwrem", |
12409
195