0.0.1 • Published 4 years ago

twitchlie v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Twitchlie

A Node.js promise-based object-oriented Twitch client API. Twitchlie attempts to provide a familiar interface to Node.js developers as an alternate to tmi.js.

This software is in early development and interfaces are not well documented and are subject to change.

Install

Not yet published to NPM.

Usage

Example

const logger = require("jethro");

const Twitch = require("twitchlie");
const twitch = new Twitch({
    username: "<twitch username>",
    password: "<twitch oauth>",
    clientId: "<twitch client id>",
    clientSecret: "<twitch client secret>"
});

twitch.connect().then(function(d) {
    logger("info", "Twitch:IRCSocket", "Connection protocol complete");
    return twitch.join(["henchmun", "fuslie"]).then((users) => {
        console.log(users);
    });
}).catch(function(e) {
    logger("error", "Twitch:API", "Fatal error occurred: " + e.message);
    console.log("fatal error");
    console.error(e);
    process.exit(1);
});

twitch.on("socket:ping", function() {
    logger("info", "Twitch:IRCSocket", "Ping received");
});

twitch.on("socket:pong", function() {
    logger("info", "Twitch:IRCSocket", "Pong sent");
});

twitch.on("socket:connected", function() {
    logger("info", "Twitch:IRCSocket", "Connected");
});

twitch.on("socket:authenticated", function(username) {
    logger("info", "Twitch:IRCSocket", `Authenticated user: ${username}`);
});

twitch.on("socket:user_join", function(data) {
    logger("info", "Twitch:IRCSocket", `${data.username} joined #${data.channel}`);
});

twitch.on("socket:user_leave", function(data) {
    logger("info", "Twitch:IRCSocket", `${data.username} left #${data.channel}`);
});

twitch.on("socket:chat", function(data) {
    logger("info", "Twitch:IRCSocket", `${data.user.username}: ${data.message}`);
});

twitch.on("socket:message", function(message) {
    //console.log(message);
});

twitch.on("socket:chat", function(data) {
    logger("info", "Twitch:IRCSocket", `${data.user.username}: ${data.message}`);
});

Licensing

This software is provided as is and without warranty.