npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

telegram-logger-monitoring

v1.0.2

Published

This package aims to simplify the capture of errors, warnings and informations by sending directly to your Telegram

Downloads

14

Readme

Telegram Logger Monitoring "Telegram"

This package aims to simplify the capture of errors, warnings and informations by sending directly to your Telegram.

First of all, you need configurate your bot on Telegram, this is required to use this package!

Follow the required steps to create a Telegram's Bot

  • Create an Telegram account
  • Search on Telegram for "BotFather"
    • Open the chat with BotFather
    • Send a message with the text /newbot
    • Send a message with the name of your bot (eg: MyAwesomeBot)
    • Send a username for your bot (eg: MyAwesomeBot_bot)

After sent the username, your bot has been created successfully, and you did receive the message whitin a directly link to the bot and the Token to use in this package.

The message received is similar to this:

Done! Congratulations on your new bot. You will find it at t.me/YOUR-USERNAME_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.

Use this token to access the HTTP API:
YOUR-BOT-TOKEN
Keep your token secure and store it safely, it can be used by anyone to control your bot.

For a description of the Bot API, see this page: https://core.telegram.org/bots/api

Configuring the package

With the bot token on your hands, you can configure the package on your application.

To configure correctly, you will need the chat_id of a particular user or a group, to get this chat id, you can follow this steps:

Note: you can send a message just for you or for a group

Send message to your particular chat_id:

Clink on t.me/YOUR-USERNAME_bot that the BotFather sent to you and send a message.

Send message to your group chat_id:

To send messages to a group, follow this steps:

  • Create a group on Telegram
  • Enter a good name
  • Add your bot on group (this is very important)

After add the bot, send a message starting with '/', eg: /start or /anything

After sent the message, open this link on your browser or Postman:

https://api.telegram.org/botYOUR-BOT-TOKEN/getUpdates

On the json response, search for the message that you sent and you'll find the chat_id

Note: if you create a group, the chat_id probably start with dash ( - ), eg: -123456789, otherwise, it can seems like 123456789

With the chat_id in your hand, you can configure the logger.

Run the command on your terminal:

npm i telegram-logger-monitoring

After, initialize the logger on your application:

Import the package's method init and call:

init(YOUR - BOT - TOKEN, YOUR - CHAT - ID);

Now, you can send test message:

await sendTestMessage();

All send message methods return this object:

{
  success: boolean;
  errorMessage?: string;
}

Follow the sendMessage method with the type of message:

await sendMessage('error', 'This is a error message');

await sendMessage('info', 'this is a info message');

await sendMessage('success', 'This is a success message');

await sendMessage('warning', 'This is a warning message');

You can pass on the firt parameters this options:

'error' | 'success' | 'info' | 'warning' | 'test';

If you need any help or improvements, feel free to send an email to [email protected]