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

node-steam-friends

v0.0.4

Published

Minimal implementation of a friends module for `node-steam`

Downloads

2

Readme

SteamFriends

This is a handler for friends related functionality, to be used with the node-steam module. It is basically a straight copy of Seishun's module here.

Initialize it by passing a SteamClient instance to the constructor.

var Steam        = require('node-steam'),
    SteamFriends = require('node-steam-friends');

var client = new Steam.SteamClient();

Steam.SteamFriends = new SteamFriends(client);

Chat-related methods automatically convert ClanIDs (group's SteamID) to ChatIDs. Conversely, ChatIDs are converted to ClanIDs in chat-related events if it's a group chat (i.e. not an "ad hoc" chat), otherwise left alone. In the following docs, chat SteamID always refers to ClanID for group chats and ChatID otherwise.

Properties

personaStates

Information about users you have encountered. It's an object whose keys are SteamIDs and values are CMsgClientPersonaState.Friend objects.

clanStates

Information about groups you have encountered. It's an object whose keys are SteamIDs and values are CMsgClientClanState objects.

chatRooms

Information about chat rooms you have joined. It's an object with the following structure:

{
  "steamID of the chat": {
    "steamID of one of the chat's current members": {
      rank: "EClanPermission",
      permissions: "a bitset of values from EChatPermission"
    }
    // other members
  }
  // other chats
}

For example, Object.keys(steamClient.chatRooms[chatID]) will return an array of the chat's current members, and steamClient.chatRooms[chatID][memberID].permissions & Steam.EChatPermission.Kick will evaluate to a nonzero value if the specified user is allowed to kick from the specified chat.

friends

An object that maps users' SteamIDs to their EFriendRelationship with you. Empty until 'relationships' is emitted. 'friend' is emitted before this object changes. Current friends have an EFriendRelationship value of 3, pending friend requests have an EFriendRelationship of 2. There are other values, documented here.

groups

An object that maps groups' SteamIDs to their EClanRelationship with you. Empty until 'relationships' is emitted. 'group' is emitted before this object changes.

Methods

setPersonaName(name)

Changes your Steam profile name.

setPersonaState(EPersonaState)

You'll want to call this with EPersonaState.Online upon logon, otherwise you'll show up as offline.

sendMessage(steamID, message, [EChatEntryType])

Last parameter defaults to EChatEntryType.ChatMsg. Another type you might want to use is EChatEntryType.Emote.

addFriend(steamID)

Sends a friend request.

removeFriend(steamID)

Removes a friend.

joinChat(steamID)

Attempts to join the specified chat room. The result should arrive in the 'chatEnter' event.

leaveChat(steamID)

Leaves the specified chat room. Will silently fail if you are not currently in it. Removes the chat from chatRooms.

lockChat(steamID), unlockChat(steamID)

Locks and unlocks a chat room respectively.

setModerated(steamID), setUnmoderated(steamID)

Enables and disables officers-only chat respectively.

kick(chatSteamID, memberSteamID), ban(chatSteamID, memberSteamID), unban(chatSteamID, memberSteamID)

Self-explanatory.

chatInvite(chatSteamID, invitedSteamID)

Invites the specified user to the specified chat.

getSteamLevel(steamids, callback)

Requests the Steam level of a number of specified accounts. The steamids argument should be an array of SteamIDs.

The single object parameter of the callback has the requested SteamIDs as properties and the level as their values. Example:

{
	"76561198006409530": 62,
	"76561197960287930": 7
}

requestFriendData(steamIDs, [requestedData])

Requests friend data. steamIDs must be an array. requestedData is optional – if falsy, defaults to EClientPersonaStateFlag.PlayerName | EClientPersonaStateFlag.Presence | EClientPersonaStateFlag.SourceID | EClientPersonaStateFlag.GameExtraInfo. The response, if any, should arrive in the 'personaState' event.

setIgnoreFriend(steamID, setIgnore, callback)

Blocks a friend if setIgnore is true, unblocks them if it's false. The first argument to callback will be EResult.

Events

'chatInvite'

  • SteamID of the chat you were invited to
  • name of the chat
  • SteamID of the user who invited you

'personaState'

Someone has gone offline/online, started a game, changed their nickname or something else. Note that the personaStates property is not yet updated when this event is fired, so you can compare the new state with the old one to see what changed.

'clanState'

Some group has posted an event or an announcement, changed their avatar or something else. Note that the clanStates property is not yet updated when this event is fired, so you can compare the new state with the old one to see what changed.

'relationships'

The friends and groups properties now contain data (unless your friend/group list is empty). Listen for this if you want to accept/decline friend requests that came while you were offline, for example.

'friend'

  • SteamID of the user
  • EFriendRelationship

Some activity in your friend list. For example, EFriendRelationship.RequestRecipient means you got a friend invite, EFriendRelationship.None means you got removed. The friends property is updated after this event is emitted.

'group'

  • SteamID of the group
  • EClanRelationship

Some activity in your group list. For example, EClanRelationship.Invited means you got invited to a group, EClanRelationship.Kicked means you got kicked. The groups property is updated after this event is emitted.

'friendMsg'

  • SteamID of the user
  • the message
  • EChatEntryType

'chatMsg'

  • SteamID of the chat room
  • the message
  • EChatEntryType
  • SteamID of the chatter

'message'

Same arguments as the above two, captures both events. In case of a friend message, the fourth argument will be undefined.

'friendMsgEchoToSender'

Same as 'friendMsg', except it is a message you send to a friend on another client.

'chatEnter'

  • SteamID of the chat room
  • EChatRoomEnterResponse

The result of attempting to join a chat. If successful, the list of chat members is available in chatRooms.

'chatStateChange'

  • EChatMemberStateChange
  • SteamID of the user who entered or left the chat room, disconnected, or was kicked or banned
  • SteamID of the chat where it happened
  • SteamID of the user who kicked or banned

Something happened in a chat you are in. For example, if the first argument equals Steam.EChatMemberStateChange.Kicked, then someone got kicked.

'chatRoomInfo'

  • SteamID of the chat
  • EChatInfoType

In case of EChatInfoType.InfoUpdate, there are two extra arguments:

  • A bitset of values from EChatFlags
  • SteamID of the user who initiated the change