Skip to content

Commit 039da77

Browse files
committed
Updated to latest node-steam v1.0.0 API.
1 parent 65cdb3f commit 039da77

1 file changed

Lines changed: 39 additions & 36 deletions

File tree

index.js

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,78 @@
11
/**
22
* node-steam-groups
3-
* node-steam extension which adds group functions
3+
* Custom node-steam handler which provides group functions
44
* Author: Michael Scholtz <michael.scholtz@outlook.com>
55
* Licence: MIT
66
*/
77
var ByteBuffer = require('bytebuffer');
88

9+
module.exports = SteamGroups;
10+
11+
function SteamGroups(steamClient) {
12+
this._client = steamClient;
13+
}
14+
915
/**
10-
* Export single function which injects new methods into Steam.
16+
* Invite another user to specific Steam group
1117
*/
12-
module.exports = function(Steam) {
13-
var EMsg = Steam.EMsg;
14-
var prototype = Steam.SteamClient.prototype;
15-
16-
prototype.acceptGroup = function(steamIdGroup) {
17-
this._send(EMsg.ClientAcknowledgeClanInvite, GroupMessages.MsgClientAcknowledgeClanInvite.serialize({
18+
SteamGroups.prototype.inviteUserToGroup = function(steamIdGroup, steamIdInvited) {
19+
this._client.send({
20+
msg: EMsg.ClientInviteUserToClan
21+
},
22+
MsgClientInviteUserToClan.serialize({
23+
steamIdInvited: steamIdInvited,
1824
steamIdGroup: steamIdGroup,
19-
acceptInvite: 1
20-
}));
21-
};
25+
unknown: 1 // I really don't know
26+
})
27+
);
28+
};
2229

23-
prototype.declineGroup = function(steamIdGroup) {
24-
this._send(EMsg.ClientAcknowledgeClanInvite, GroupMessages.MsgClientAcknowledgeClanInvite.serialize({
30+
/**
31+
* Accept/decline group invite
32+
*/
33+
SteamGroups.prototype.acknowledgeGroupInvite = function(steamIdGroup, response) {
34+
this._client.send({
35+
msg: EMsg.ClientAcknowledgeClanInvite
36+
},
37+
MsgClientAcknowledgeClanInvite.serialize({
2538
steamIdGroup: steamIdGroup,
26-
acceptInvite: 0
27-
}));
28-
};
39+
response: +response
40+
})
41+
);
42+
};
2943

30-
prototype.groupInvite = function(steamIdGroup, steamIdInvited) {
31-
this._send(EMsg.ClientInviteUserToClan, GroupMessages.MsgClientInviteUserToClan.serialize({
32-
steamIdInvited: steamIdInvited,
33-
steamIdGroup: steamIdGroup,
34-
unknown: 1
35-
}));
36-
};
44+
/**
45+
* Define additional EMsg codes
46+
*/
47+
var EMsg = {
48+
ClientInviteUserToClan: 744,
49+
ClientAcknowledgeClanInvite: 745
3750
};
3851

3952
/**
4053
* Define additional Steam messages
4154
*/
42-
var GroupMessages = {};
43-
4455
// Sending group invites
4556
var MsgClientInviteUserToClan = {
46-
baseSize: 17,
47-
4857
serialize: function(object) {
4958
var buffer = new ByteBuffer(17, ByteBuffer.LITTLE_ENDIAN);
5059

5160
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdInvited) || 0);
5261
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdGroup) || 0);
5362
buffer.writeUint8(object.unknown || 0);
5463

55-
return buffer.flip();
64+
return buffer.flip().toBuffer();
5665
}
5766
};
5867

59-
GroupMessages.MsgClientInviteUserToClan = MsgClientInviteUserToClan;
60-
6168
// Accepting/declining group invites
6269
var MsgClientAcknowledgeClanInvite = {
63-
baseSize: 9,
64-
6570
serialize: function(object) {
6671
var buffer = new ByteBuffer(9, ByteBuffer.LITTLE_ENDIAN);
6772

6873
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdGroup) || 0);
69-
buffer.writeUint8(object.acceptInvite || 0);
74+
buffer.writeUint8(object.response || 0);
7075

71-
return buffer.flip();
76+
return buffer.flip().toBuffer();
7277
}
7378
};
74-
75-
GroupMessages.MsgClientAcknowledgeClanInvite = MsgClientAcknowledgeClanInvite;

0 commit comments

Comments
 (0)