Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@puregram/markup
Advanced tools
simple yet powerful markup system for puregram
package
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
!
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()
$ yarn add @puregram/markup
$ npm i -S @puregram/markup
all of the functions except those that require two or more arguments can be called either via template strings or like basic functions
// template strings
bold`foo ${italic`bar`}`
// parentheses
bold(italic('bar'))
there's literally no distinction between them, however if you are going to do embedded markup, you should use template strings:
// ✅ works
bold`foo ${italic`bar`}`
bold`${italic`bar`}`
bold(italic('bar'))
// ❌ does not work
bold(`foo ${italic('bar')}`)
bold(`${italic('foo')}`)
the last one does not work simply because javascript compiles foo ${italic('bar')}
into a single string which becomes 'foo [object Object]' soo yeah
format(strings: TemplateStringsArray, ...rest: Rest)
formats the template and strips first pack of spaces from all lines (stripIndent
-like)
format`
hello!
those two spaces at the start will be stripped
but those additional two spaces wont
`
formatDedent(strings: TemplateStringsArray, ...rest: Rest)
this one acts like format
except it... ugh just roll the credits code example
format`
hello!
those two spaces at the start will be stripped
those additional two will also be stripped
and those additional 18 spaces too!
`
(stripIndents
-like)
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: string, language?: string)
pre('im cool')
pre('im cool but in bash', 'sh')
link(text: string, url: string)
link('epic!', 'https://github.puregram.cool')
mentionUser(text: string, userId: number)
mentionUser('dude', 398859857)
mentionBot(text: string, userId: number)
mentionUser('robodude', telegram.bot.id)
textMention(text: string, user: Interfaces.TelegramUser)
mentionUser('dude', { id: 398859857, is_bot: false, first_name: 'dude' })
customEmoji(text: string, id: string)
customEmoji('😁', '...')
FAQs
simple yet powerful markup system for puregram
The npm package @puregram/markup receives a total of 0 weekly downloads. As such, @puregram/markup popularity was classified as not popular.
We found that @puregram/markup demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.