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

hack-chat

v1.2.0

Published

API wrapper for hack.chat using ws package

Downloads

13

Readme

hack.chat.js

npm package 1.2.0

API wrapper for hack.chat using ws package

Usage

var HackChat = require("hack-chat");
var chat = new HackChat(); // Client group for multiple channels
chat.join("lobby", "TestUser");
var programmingSession = chat.join("programming", "TestUser");

chat.on("onlineSet", function(session, users) {
    // Each event from a group contains a session argument as first argument
    console.log("Users online in ?" + session.channel + ": " + users.join(", "));
});

chat.on("chat", function(session, nick, text) {
    console.log(nick + "@" + session.channel + ": " + text);

    if (session.channel != "programming") {
        programmingSession.sendMessage("Quote from ?" + session.channel + ": " + text);
    }
});

HackChat.Session methods

new(channel: string, username: string, password?: string, options?: any = { server: "wss://hack.chat/chat-ws" })

Description: Constructs a new chat session and directly connects to it

Example:

var session = new HackChat.Session("programming", "My_Username", "password123", { server: "wss://custom-server.com/chat-ws" });

sendRaw(json: any)

Description: Sends a raw JSON packet

Example:

session.sendRaw({ cmd: "ping" });

sendMessage(message: string)

Description: Sends a chat message

Example:

session.sendMessage("Hi everybody");

invite(user: string)

Description: Invites a user to a random channel

Example:

session.on("invited", function(nick, channel, time) {
    var invitedSession = chat.join(channel, "My_Username", "password123");
    invitedSession.once("onlineAdd", function(nick, time)
    {
        invitedSession.sendMessage("Hi, " + nick);
    });
});

session.invite("WebFreak");

ping()

Description: Sends a ping packet. Can be used to check IP limit.

leave()

Description: Disconnects from the server, making this unusable

HackChat.Session events

All HackChat events are the same as the HackChat.Session events with the exception that the session where it got emitted from is the first argument

.on("joining")

Description: Emitted when sending the join request.

Arguments: None

.on("left")

Description: Emitted when disconnected from WebSocket.

Arguments: None

.on("chat")

Description: Emitted when someone sends a regular message.

Arguments:

  • nick (String)
  • text (String)
  • time (Number, Unix Time)
  • isAdmin (Boolean)
  • trip (String) - Hash from password

.on("info")

Description: Emitted when some unhandled info event passes through.

Arguments:

  • text (String)
  • time (Number, Unix Time)

.on("infoRaw")

Description: Emitted when any info event occurs. Will also trigger if it gets handled.

Arguments:

  • text (String)
  • time (Number, Unix Time)

.on("warn")

Description: Emitted when some unhandled warn event passes through.

Arguments:

  • text (String)
  • time (Number, Unix Time)

.on("warnRaw")

Description: Emitted when any warn event occurs. Will also trigger if it gets handled.

Arguments:

  • text (String)
  • time (Number, Unix Time)

.on("ratelimit")

Description: Emitted when server is sending IP ratelimit warning. Will cancel regular warn event.

Arguments:

  • time (Number, Unix Time)

.on("banned")

Description: Emitted when admin is banning the user. Will cancel regular warn event.

Arguments:

  • time (Number, Unix Time)

.on("nicknameInvalid")

Description: Emitted when nickname trying to join with is invalid ("!", "$", "?", etc.) Will cancel regular warn event.

Arguments:

  • time (Number, Unix Time)

.on("nicknameTaken")

Description: Emitted when nickname trying to join with is already taken. Will cancel regular warn event.

Arguments:

  • time (Number, Unix Time)

.on("invited")

Description: Emitted when WebSocket successfully invited someone. Will cancel regular info event.

Arguments:

  • nick (String)
  • channel (String)
  • time (Number, Unix Time)

.on("invitation")

Description: Emitted when someone invited WebSocket. Will cancel regular info event.

Arguments:

  • nick (String)
  • channel (String)
  • time (Number, Unix Time)

.on("onlineSet")

Description: Emitted when successfully joined. Will contain an array of users.

Arguments:

  • nicks (String[])
  • time (Number, Unix Time)

.on("onlineAdd")

Description: Emitted when someone joins the channel.

Arguments:

  • nick (String)
  • time (Number, Unix Time)

.on("onlineRemove")

Description: Emitted when someone leaves the channel.

Arguments:

  • nick (String)
  • time (Number, Unix Time)

.on("error")

Description: Emitted when receiving invalid JSON or if WebSocket fails to send.

Arguments:

  • exception (any)