New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@puregram/markup

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@puregram/markup

simple yet powerful markup system for puregram

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

puregram  •  telegram forum

@puregram/markup

simple yet powerful markup system for puregram package

introduction

you all know how you need to provide parse_mode every time you send a message with a markdown or html, right? it might get a little boring after first few hundreds of times, so i present to you @puregram/markup!

example

const { format, bold, italic, code, hooks: formatHooks } = require('@puregram/markup')

const { Telegram } = require('puregram')

const telegram = Telegram.fromToken(process.env.TOKEN)

// we use hooks for this one
telegram.useHooks(formatHooks())

telegram.updates.on('message', (context) => {
  return context.send(
    format`hey! this ${bold('message')} is ${italic('formatted')} without ${code('parse_mode')}!`
  )
})

telegram.updates.startPolling()

installation

$ yarn add @puregram/markup
$ npm i -S @puregram/markup

usage

most of the functions can be used via template strings, basic ones can be used via the, you know, parentheses

// template strings
bold`foo ${italic`bar`}`

// parentheses
bold(`foo ${italic('bar')}`)

there's literally no distinction between them i suppose

also dont use nested template strings, they may have a few bugs


available functions

bold(text: string)

bold('hey!')
bold`hey!`

italic(text: string)

italic('hey!')
italic`hey!`

code(code: string)

code('const x = 5')
code`const x = 5`

underline(text: string)

underline('hey!')
underline`hey!`

strikethrough(text: string)

strikethrough('hey!')
strikethrough`hey!`

spoiler(text: string)

spoiler('hey!')
spoiler`hey!`

mention(text: string)

mention('@username')
mention`@username`

pre(text: TemplateStringsArray)

pre`const x = 5\nconst y = x ** 2`

pre(language?: string)(text: TemplateStringsArray)

pre('js')`const x = 5\nconst y = x ** 2`

link(url: string)(text: TemplateStringsArray)

link('github.puregram.cool')`epic!`

mentionUser(user: Interfaces.TelegramUser | Structures.User)(text: TemplateStringsArray)

mentionUser({ id: 123, is_bot: false, first_name: 'dude' })`dude`

customEmoji(id: string)(text: TemplateStringsArray)

customEmoji('...')`😁`

Keywords

FAQs

Package last updated on 22 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc