tg-cli-node

0.0.8 • Public • Published

tg-cli-node

Node.js wrapper for telegram-cli

Docs

How to use

Install package from npm:

npm install tg-cli-node

Create config.js with:

const path = require('path');
 
module.exports = {
    telegram_cli_path: path.join(__dirname, 'tg/bin/telegram-cli'), //path to tg-cli (see https://github.com/vysheng/tg)
    telegram_cli_socket_path: path.join(__dirname, 'socket'), // path for socket file
    server_publickey_path: path.join(__dirname, 'tg/tg-server.pub'), // path to server key (traditionally, in %tg_cli_path%/tg-server.pub)
}

Open your app script and use this example:

const TelegramAPI = require('tg-cli-node');
const config = require('./config');
 
const Client = new TelegramAPI(config);
 
Client.connect(connection => {
    connection.on('message', message => {
        console.log('message:', message);
    });
 
    connection.on('error', e => {
        console.log('Error from Telegram API:', e);
    });
 
    connection.on('disconnect', () => {
        console.log('Disconnected from Telegram API');
    });
});

Readme

Keywords

none

Package Sidebar

Install

npm i tg-cli-node

Weekly Downloads

9

Version

0.0.8

License

GNU GPLv3

Last publish

Collaborators

  • perkovec