npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hitbox-chat

v0.1.5

Published

A chat client library for hitbox.tv

Downloads

22

Readme

hitbox-chat

A chat client library for hitbox.tv

API

HitboxChatClient

HitboxChatClient(opts:Object)

Constructs a hitbox.tv chat client. Exposed as the result of calling require("hitbox-chat")

opts = null
     | { user: "tsholmes", pass: "hunter2" }
     | { user: "tsholmes", token: "0123456789abcdef0123456789abcdef0123457" }

HitboxChatClient#on(event:String, callback:Function)

Adds an event listener

(event, callback) = ("connect",    Function())
                  | ("disconnect", Function());

HitboxChatClient#joinChannel(channel:String):HitboxChannel

Joins a channel and returns the channel object

HitboxChannel

HitboxChannel#on(event:String, callback:Function)

Adds an event listener

(event, callback) = ("login",  Function(name:String, role:String))
                  | ("chat",   Function(name:String, text:String, role:String))
                  | ("motd",   Function(text:String))
                  | ("slow",   Function(slowTime:Number))
                  | ("info",   Function(text:String))
                  | ("poll",   Function(poll:HitboxPoll))
                  | ("raffle", Function(raffle:HitboxRaffle))
                  | ("other",  Function(method:String, params:Object)

HitboxChannel#join()

(Re)joins the channel with the credentials specified in the client.

HitboxChannel#leave()

Leaves the channel. Stops receiving events on this channel (once the server receives the leave request).

HitboxChannel#sendMessage(text:String, nameColor:String)

Sends a message to this channel with the given name color (or the default color if null)

HitboxChannel#defaultColor:String

The default name color when sending messages

HitboxPoll

HitboxPoll#on(event:String, callback:Function)

Adds an event listener

(event, callback) = ("pause", Function())
                  | ("start", Function()) // sent on restart after pause
                  | ("vote",  Function()) // sent when (every time?) someone new votes
                  | ("end",   Function())

HitboxPoll#vote(choice:Number)

Votes for the choice specified by (0-based) index choice.

HitboxPoll#startTime:Date

The time the poll was started

HitboxPoll#status:String

The status of the poll. One of { started, paused, ended }.

HitboxPoll#question:String

The question the poll is asking.

HitboxPoll#choices:Array[Object]

The choices for responding to the poll.

choices = [
  { text: "choice 0", votes: 1 },
  { text: "choice 1", votes: 4 },
  ...
]

HitboxPoll#voters:Array[String]

The list of usernames that voted in the poll.

HitboxPoll#votes:Number

The number of votes cast in the poll. (same as voters.length)

HitboxRaffle

HitboxRaffle#on(event:String, callback:Function)

Adds an event listener

(event, callback) = ("pause",  Function()) // picking winner
                  | ("start",  Function()) // restart after pause
                  | ("vote",   Function())
                  | ("end",    Function()) // winner chosen
                  | ("hide",   Function()) // hidden after winner chosen
                  | ("delete", Function()) // deleted
                  | ("winner", Function(name:String, email:String)) // (ADMIN ONLY) name and email of winner
                  | ("win",    Function()) // (CLIENT ONLY) you won!

HitboxRaffle#vote(choice:Number)

Votes for the choice specified by (0-based) index choice.

HitboxRaffle#startTime:Date

The time the raffle was started

HitboxRaffle#status:String

The status of the raffle. One of { started, paused, ended, hidden, deleted}.

HitboxRaffle#question:String

The question or title of the raffle.

HitboxRaffle#Choices:Array[Object]

The choices for responding to the raffle.

choices = [ // ADMIN
  { text: "choice 0", count: 1 },
  { text: "choice 1", count: 2 },
  ...
]
choices = [ // CLIENT
  { text: "choice 0" },
  { text: "choice 1" },
  ...
]

##Example Usage

var HitboxChatClient = require("hitbox-chat");

// (username, token) or () for guest
var client = new HitboxChatClient({user:"tsholmes", pass:"hunter2"});
client.on("connect", function() {
  // handle connect
  var channel = client.joinChannel("tsholmes");
  channel.on("login", function(name, role) {
    /*
     * successfully joined channel
     * role is one of {
     *   guest: read-only (bad or no credentials)
     *   anon: normal read/write
     *   user: mod
     *   admin: owner/staff
     * }
     */
  }).on("chat", function(name,text,role) {
    // chat message received
    channel.sendMessage("Hi " + name, "00FF00");
  }).on("motd", function(text) {
    // message of the day changed
  }).on("slow", function(slowTime) {
    // slow mode enabled. limited to 1 message every slowTime seconds
  }).on("info", function(text) {
    // info message (bans, kicks, etc)
  }).on("poll", function(poll) {
    // poll started
    poll.vote(0);
  }).on("raffle", function(raffle){
    // raffle started
    raffle.vote(0);
    raffle.on("win", function() {
      // you won!
    });
  }).on("other", function(method,params) {
    // something else that isn't handled yet. params is raw event JSON
  });
}).on("disconnect", function() {
  // handle disconnect
});