0.9.1 • Published 6 years ago
@dlghq/dialog-node-client v0.9.1
Dialog Node.js client
Installation
yarn add @dlghq/dialog-node-client
Usage
const path = require('path');
const { Bot } = require('@dlghq/dialog-node-client');
const bot = new Bot(
// endpoints
['wss://ws1.dlg.im'],
// user credentials
{ phone: '75555555555', code: '5555' }
);
bot.onMessage(async (update) => {
// get self uid
const uid = await bot.getUid();
// check if message contents photo
if (update.content.type === 'photo') {
// load photo url
const url = await bot.loadFileUrl(update.content.file);
// and send it back to the client
await bot.sendTextMessage(update.peer, `Thanks for photo: ${url}`);
// send file as image
await bot.sendPhotoMessage(update.peer, path.resolve(__dirname, 'dinotocat.png'));
} else {
// send text message
await bot.sendTextMessage(update.peer, 'Hello =)');
}
});
// handle errors
bot.on('error', (error) => {
console.error(error);
process.exit(1);
});
0.9.1
6 years ago
0.9.0
6 years ago
0.8.1
6 years ago
0.8.0
7 years ago
0.7.1
7 years ago
0.7.0
7 years ago
0.6.0
7 years ago
0.5.3
7 years ago
0.5.2
7 years ago
0.5.1
7 years ago
0.5.0
7 years ago
0.4.1
7 years ago
0.4.0
7 years ago
0.3.1
7 years ago
0.3.0
7 years ago
0.2.0
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.0.0
7 years ago