Socket
Socket
Sign inDemoInstall

slimbot

Package Overview
Dependencies
53
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    slimbot

Simple and minimal Telegram Bot API for Node.js. No frills.


Version published
Weekly downloads
371
decreased by-7.02%
Maintainers
1
Install size
2.84 MB
Created
Weekly downloads
 

Readme

Source

Build Status Coverage Status Dependency Status MIT licensed

Slimbot

A fuss-free, thin wrapper around Telegram Bot API for Node.js. No frills.

Updated for Bot API 3.2, allowing your bot to police chat groups and handle stickers/sticker sets.

Resources

Getting started

npm i slimbot
const Slimbot = require('slimbot');
const slimbot = new Slimbot(process.env['TELEGRAM_BOT_TOKEN']);

// Register listeners

slimbot.on('message', message => {
  slimbot.sendMessage(message.chat.id, 'Message received');
});

// Call API

slimbot.startPolling();

Now go ahead and type a message to your bot in Telegram. It should reply you with 'Message received' in the chat.

All methods return a promise. This means you can inspect the returned objects if you want to:

slimbot.sendMessage('123456789', 'Message received')
  .then(message => {
    console.log(message);
  });

In this case, the sendMessage method returns a Message object as stated in the documentation.

You can also use callbacks instead of promises:

const Slimbot = require('./src/slimbot');
const slimbot = new Slimbot(process.env['TELEGRAM_BOT_TOKEN']);

function callback(err, obj) {
  if (err) {
    // handle error
    console.log(obj);
  }
  // handle returned object
  console.log(obj);
};

slimbot.on('message', message => {
  slimbot.sendMessage(message.chat.id, 'Message received', callback);
});

slimbot.startPolling(callback);

Examples

Documentation (Wiki)

Learn more about the implementation details in the Wiki. Feel free to contribute to the Wiki or add more examples.

Contributing

The guiding principle for this library is to be as simple as possible. I put serious thought into adding features to guard against bloat. Nonetheless, I am very open to dialogue and contributions are most welcome.

If you have built a public bot using this library, send me a PM and I'll feature it here.

Keywords

FAQs

Last updated on 10 Aug 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc