-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
78 lines (67 loc) · 1.98 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* node-steam-groups
* Custom node-steam handler which provides group functions
* Author: Michael Scholtz <[email protected]>
* Licence: MIT
*/
var ByteBuffer = require('bytebuffer');
module.exports = SteamGroups;
function SteamGroups(steamClient) {
this._client = steamClient;
}
/**
* Invite another user to specific Steam group
*/
SteamGroups.prototype.inviteUserToGroup = function(steamIdGroup, steamIdInvited) {
this._client.send({
msg: EMsg.ClientInviteUserToClan
},
MsgClientInviteUserToClan.serialize({
steamIdInvited: steamIdInvited,
steamIdGroup: steamIdGroup,
unknown: 1 // I really don't know
})
);
};
/**
* Accept/decline group invite
*/
SteamGroups.prototype.acknowledgeGroupInvite = function(steamIdGroup, response) {
this._client.send({
msg: EMsg.ClientAcknowledgeClanInvite
},
MsgClientAcknowledgeClanInvite.serialize({
steamIdGroup: steamIdGroup,
response: +response
})
);
};
/**
* Define additional EMsg codes
*/
var EMsg = {
ClientInviteUserToClan: 744,
ClientAcknowledgeClanInvite: 745
};
/**
* Define additional Steam messages
*/
// Sending group invites
var MsgClientInviteUserToClan = {
serialize: function(object) {
var buffer = new ByteBuffer(17, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdInvited) || 0);
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdGroup) || 0);
buffer.writeUint8(object.unknown || 0);
return buffer.flip().toBuffer();
}
};
// Accepting/declining group invites
var MsgClientAcknowledgeClanInvite = {
serialize: function(object) {
var buffer = new ByteBuffer(9, ByteBuffer.LITTLE_ENDIAN);
buffer.writeUint64(ByteBuffer.Long.fromString(object.steamIdGroup) || 0);
buffer.writeUint8(object.response || 0);
return buffer.flip().toBuffer();
}
};