New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dlghq/dialog-node-client

Package Overview
Dependencies
Maintainers
6
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dlghq/dialog-node-client

Dialog Node.js client =====================

  • 0.9.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-81.25%
Maintainers
6
Weekly downloads
 
Created
Source

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);
});

More examples

FAQs

Package last updated on 08 Feb 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc