https://github.com/perkovec/tg-cli-node
Node.js wrapper for telegram-cli
https://github.com/perkovec/tg-cli-node
node-wrapper telegram-cli tg-cli-node
Last synced: 7 months ago
JSON representation
Node.js wrapper for telegram-cli
- Host: GitHub
- URL: https://github.com/perkovec/tg-cli-node
- Owner: Perkovec
- Created: 2016-08-30T22:30:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-01T15:40:45.000Z (about 6 years ago)
- Last Synced: 2025-07-08T18:08:41.464Z (7 months ago)
- Topics: node-wrapper, telegram-cli, tg-cli-node
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 26
- Watchers: 7
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tg-cli-node
Node.js wrapper for [telegram-cli](https://github.com/vysheng/tg)
[Docs](https://github.com/Perkovec/tg-cli-node/wiki/Documentation)
## How to use
Install package from npm:
```bash
npm install tg-cli-node
```
Create `config.js` with:
```javascript
const path = require('path');
const os = require('os');
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( os.tmpdir(), '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:
```javascript
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');
});
});
```