README
vimmtv npm package
This npm package provides basic access to the Vimm.TV API as well as to the livestream chat.
Installation
npm i vimmtv --save
Usage
import {Web, Chat} from 'vimmtv';
//Get all current live streams
const liveStreams = await WebApi.getLivestreams();
//Get one random stream
const randomStream = liveStreams[Math.floor(Math.random() * liveStreams.length)];
//define chat socket functions:
let onOpen = (channel) => {
console.log("Connected to #" + channel)
};
let onMessage = (message) => {
if (message.mtype === "message") {
console.log(message.chatter + ":", message.message)
}
if (message.mtype === "signal") {
console.log("> " + message.chatter + " ping")
}
};
let onError = (error) => {
throw new Error(error.message)
};
//connect to chat of randomStream
new Chat(randomStream.display_name, onOpen, onMessage, onError);
Methods
Get the status of a channel:
Web.getStatus(channel)
Get chat presences of a channel:
Web.getPresence(channel)
Get all live streams:
Web.getLivestreams()
Connect to a live chat:
new Chat(channel, onopen, onmessage, onerror)
For a working example check the example.js
License
MIT