
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
tgast-util-to-telegram-entity
Advanced tools
tgast utility that turns a tgast syntax tree into a Telegram message with entities.
tgast utility that converts a tgast tree into a Telegram message with entities.
This package turns a tgast syntax tree into a plain Telegram message, with formatting preserved using message entities.
It is used in regram-parse
and helps with transforming
Telegram content.
Use this if you work directly with syntax trees and want to output Telegram messages. If you prefer a simpler way to process content, check out regram.
# deno
deno add npm:tgast-util-to-telegram-entity
# bun
bun add tgast-util-to-telegram-entity
# pnpm
pnpm add tgast-util-to-telegram-entity
# yarn
yarn add tgast-util-to-telegram-entity
# npm
npm install tgast-util-to-telegram-entity
Say we have this tgast tree:
import type { Root } from 'tgast-util-to-telegram-entity'
import { toTelegramEntity } from 'tgast-util-to-telegram-entity'
const tree: Root = {
type: 'root',
children: [
{
type: 'bold',
children: [
{
type: 'text',
value: 'This is a bold text.',
},
],
},
],
}
const message = toTelegramEntity(tree)
console.log(message)
...now the console.log(message)
will yield:
{
"text": "This is a bold text.",
"entities": [
{
"offset": 0,
"length": 20,
"type": "bold"
}
]
}
Exports:
toTelegramEntity
,Root
.Message
,MessageEntity
,There is no default export.
toTelegramEntity
function toTelegramEntity(tree: Root): Message
Converts a tgast tree into a plain Telegram message with entities.
Type reference: https://github.com/tgast-ecosystem/tgast-util-to-telegram-entity/blob/main/src/to-telegram-entity.ts#L12
Root
) — A tgast syntax tree.A Message
with text
and entities
.
Root
interface Root {
type: 'root'
position?: Position
data?: RootData
children: RootContent[]
}
The root node of the tgast tree.
Type reference: https://github.com/tgast-ecosystem/tgast/blob/main/src/nodes/root.ts#L16-L25
Message
interface Message {
text: string
entities: MessageEntity[]
}
Represents a Telegram message with formatted text.
Type reference: https://github.com/tgast-ecosystem/tgast-util-to-telegram-entity/blob/main/src/types/message.type.ts#L4-L11
string
) — The plain text of the message.MessageEntity[]
) — Special parts like bold
,
url
, and mention
.MessageEntity
interface MessageEntity {
type: string
offset: number
length: number
language?: string
custom_emoji_id?: string
url?: string
user?: {
id: number
is_bot: boolean
first_name: string
last_name?: string
username?: string
language_code?: string
is_premium?: true
added_to_attachment_menu?: true
}
}
Represents a formatting part of the message like bold
, url
, or mention
.
Type reference: https://github.com/grammyjs/types/blob/main/message.ts#L507-L562
FAQs
tgast utility that turns a tgast syntax tree into a Telegram message with entities.
We found that tgast-util-to-telegram-entity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.