Skip to main content

2 posts tagged with "formatting"

View All Tags

· One min read
Vitali Haradkou

The new telegraph component was landed and available on npm.js site.

analytics

This components listen any chat iteraction with user and emits events with analytics prefix.

Analytics components also defines PluginAPI to write a custom extensions for analytics. See docs how to work with plugins.

Installation:

npm i @tlgr/analytics

How it works:

example.ts
import { Analytics } from "@tlgr/analytics";
import { Console } from "@tlgr/analytics/plugins";
import { Telegraf } from "telegraf";

const bot = new Telegraf("<API TOKEN>");

const analytics = new Analytics(bot, new Console());

analytics.enable(true); // true - launch imidiately
bot.start((ctx) => {
// send message
ctx.reply(/** reply message */);
});

// fires event with start command, and reply text as param.

JSX support for fmt package.

For now, when you want to reply message, you can use JSX markup. See docs how to enable JSX support

Full Changelog available at link: https://github.com/vitalics/Telegraph/blob/main/releases/v1.4.0.md

· One min read
Vitali Haradkou

Version 1.2 was missed due to releasing issue.

The new telegraph component was landed and available on npm.js site.

fmt

This is not actually a "component" but it includes helpful formatting

Installation:

npm i @tlgr/fmt

How it works:

example.ts
import { fmt, bold } from "@tlgr/fmt";
import { Telegraf } from "telegraf";

const bot = new Telegraf("<API TOKEN>");

bot.start((ctx) => {
// send message
ctx.reply(...fmt(`Hello with ${bold("bold")} message`)); // hello with bold message
});

bot.launch();

Full Changelog available at link: https://github.com/vitalics/Telegraph/blob/main/releases/v1.3.0.md

Made with ❤️ from vitalics