Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
README.md Fix documentation for requestFriendData Jul 31, 2015
index.js Add 'chatRoomInfo' event Jul 29, 2015

README.md

SteamFriends

This is a handler for Community functionality. Initialize it by passing a SteamClient instance to the constructor.

var steamFriends = new Steam.SteamFriends(steamClient);

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.

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