dlive-javascript-sdk
Unofficial dlive.tv api
Last updated a year ago by iameli .
MIT · Original npm · Tarball · package.json
$ cnpm install dlive-javascript-sdk 
SYNC missed versions from official npm registry.

This project was forked from the last MIT-redistributable commit of dlive-unofficial-api-js. They've moved to a non-OSI approved license; this fork will remain MIT licensed.

Discord GitHub npm <img alt="Travis" src="https://img.shields.io/travis/com/iameli/dlive-javascript-sdk.svg?style=for-the-badge"

Example

const  { Dlive } = require('dlive-javascript-sdk')

const blockchainName = 'YOUR BLOCKCHAIN NAME (e.g. dlive-1234567890)' // Our Blockchain username
const accessKey = 'YOUR KEY' // Our access key

// Chat cooldown
const coolDown = 3000 // 3 seconds

// Parameter 1: Blockchain username
// Parameter 2: Your access key for sending messages
let example = new Dlive(blockchainName, accessKey) // Joining sampepper

example.on('ChatText', (message) => {
  console.log(`Messages in Channel ${example.getChannel}: ${message.content}`)

  if (message.content === '!song') {
    example.sendMessage('Currently no track available...').then((result) => {
      console.log('Message sended!')
      console.log(result)
    }).catch((error) => {
      console.log(`Error while sending message! ${error}`)
      // Now we can use our function to try to resend, at this point you would directly use our own function. Please do not use this example in productive use, because it is ...
      sendMessage('Currently no track available...')
    })
  }
})

example.on('ChatFollow', (message) => {
  // Say thanks to this user for his follow!
  sendMessage(`Thanks for the follow, @${message.sender.displayname}`)
})

example.on('ChatGift', (message) => {
  // Say thanks to this user for his gift!
  sendMessage(`Thanks for ${message.amount}x ${message.gift}, @${message.sender.displayname}`)
})

// Get our channel informations
example.getChannelInformationByDisplayName('pewdiepie' /* enter a displayname, not the Blockchain username */).then((result) => {
  console.log(result)
}).catch((error) => {
  console.log(error)
})

function sendMessage (message) {
  example.sendMessage(message).catch((error) => {
    console.log(`Oh no.. error! ${error} - Retry in ${coolDown / 1000} seconds!`)
    setTimeout(sendMessage, coolDown, message)
  })
}

Current Tags

  • 2.1.13                                ...           latest (a year ago)

2 Versions

  • 2.1.13                                ...           a year ago
  • 2.1.13-test-000                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (3)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |