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

error-shout-bot

v0.0.7

Published

Library for using telegram to send error messages from your applicaiton

Downloads

3

Readme

error-shout-bot

Don't let your errors be silent, let them shout!

error-shout-bot a library that uses Telegram to send messages from your application. Get real-time messages from your application directly to your phone or PC.

dependencies up to date

npm version

Build Status #error-shout-bot

Installation & Configuration

error-shout-bot is available as a npm package

npm install error-shout-bot --save

Import the library and intialise it

var ErrorShout = require('error-shout-bot');
var Shout = new ErrorShout(botToken, chatId);

botToken is a string that is unique to your bot. New bots and bot tokens can be requested from the Telegram BotFather.

chatId is a string representing where you want the messages to get posted. There are 3 options for this:

  1. Individual user's chatId - e.g. "123456789" - Find out you own by starting a chat with IDBot. NOTE: You need to start a conversation with your bot before it can message you
  2. Group's chatId - e.g. "-123456789" - Find out a groups chat Id by adding IDBot to the group. NOTE: Your bot needs to be added to the group before it can post in it.
  3. Channels - e.g "@ErrorChannelName" - NOTE: Your bot needs to be admin of a channel to post in it.

Usage

getBotName()

returns a promise that resolves with the bots name

Shout.getBotName()
.then(function(name){
  console.log(name);
});

-- sendError with object --

sendError(messageObject)

returns a promise that will format messageObject and send the message to configured chatId

Shout.sendError({
  message: 'An error with a complex object',
  error: {
    levelOne: {
      levelTwo: {
        levelThree: {
          usefulInfo: '1+1=2'
        }
      }
    }
  },
  anyRandomKey: 'meow',
  number: 123,
  boolean: false
});
.then(function(responseFromTelegramApi){
  console.log('message sent');
})
.catch(function(error){
  //Error from request or telegram
  console.log(error);
});
Example message's output:

Date: Mon Apr 25 2016 13:20:25 GMT+0100 (IST)

message: An error with a complex object

error:

{
  levelOne: {
    levelTwo: {
      levelThree: {
        usefulInfo: "1+1=2"
      }
    }
  }
}

anyRandomKey:

meow

number:

123

boolean:

false

-- sendError with strings --

sendError(message, source, methodName, detail)

returns a promise that will send the message to configured chatId

Shout.sendError('Oh no, an error', 'error-shout-bot-example', 'doingSomething' 'This could be a description of why this was sent')
.then(function(responseFromTelegramApi){
  console.log('message sent');
})
.catch(function(error){
  //Error from request or telegram
  console.log(error);
});

The "source", "methodName" and "detail" parameters of sendError are optional

Shout.sendError('Oh no - This is an error');
Example of the message output:

Date: Mon Apr 25 2016 13:20:25 GMT+0100 (IST)

Source: error-shout-bot example

MethodName: doSomething

Detail: Failed to do something.

Error:

TypeError: Cannot read property 'doSomething' of null