telegram-basic-bot

1.0.1 • Public • Published

Telegram Basic Bot

API Documentation

This is a basic telegram bot wrapper that has no dependencies and will run on basically any node version. This is great for anyone

Install

Just copy telegram.js into your project. There are no dependencies, and you'll definitely be getting the source code right here.

Alternatively, use npm (not recommended)

npm install --save node-telegram-bot-api

Usage

The basic bot uses the EventEmitter pattern when getting events, and standard error first callbacks

var TelegramClient = require('./telegram');
var telegram = new TelegramClient(token);
 
// send a message
telegram.request('sendMessage', { chat_id: '@mychannel', text: 'hello world' });
 
// get a file
telegram.requst('getFile', { file_id: fileId }, function(err, file) {
    // do whatever
});
 
// polling or webhook
telegram.poll(['message']);
 
// not implemented yet
telegram.listen(['message']);

Named methods

As a convenience, named methods can be generated to shorten calling. This is not recommended as there is no guarantee that these methods will be kept up to date with new API additions. If using this feature, methods.js is also required.

var telegram = new TelegramClient(token, true);
 
telegram.getMe({}, function(err, data) {
    console.log(data);
});

Promises

Fuck off

Package Sidebar

Install

npm i telegram-basic-bot

Weekly Downloads

0

Version

1.0.1

License

WTFPL

Unpacked Size

8.51 kB

Total Files

5

Last publish

Collaborators

  • azhao12345