steamutils 1.1.96 → 1.1.98
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/SteamClient.js +20 -4
- package/index.js +25 -3
- package/package.json +1 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/SteamClient.js
CHANGED
@@ -87,10 +87,12 @@ function SteamClient({
|
|
87
87
|
isPartyRegister = true,
|
88
88
|
autoPlay = false,
|
89
89
|
autoAcceptTradeRequest = false,
|
90
|
+
autoReconnect = true,
|
90
91
|
}) {
|
91
92
|
const steamClient = new SteamUser()
|
92
93
|
let prime = null
|
93
94
|
let state = 'Offline'//InGame, Online
|
95
|
+
let isLogOff = false
|
94
96
|
|
95
97
|
const events = {
|
96
98
|
user: [],
|
@@ -372,6 +374,12 @@ function SteamClient({
|
|
372
374
|
log('disconnected', eresult, msg)
|
373
375
|
doClearIntervals()
|
374
376
|
callEvent(events.disconnected, {eresult, msg})
|
377
|
+
|
378
|
+
if (eresult === 3 && autoReconnect && !isLogOff) {
|
379
|
+
setTimeout(function () {
|
380
|
+
login(true)
|
381
|
+
}, 30000)
|
382
|
+
}
|
375
383
|
})
|
376
384
|
steamClient.on('error', async (e) => {
|
377
385
|
let errorStr = ``
|
@@ -1040,21 +1048,28 @@ function SteamClient({
|
|
1040
1048
|
}
|
1041
1049
|
}
|
1042
1050
|
|
1043
|
-
async function login() {
|
1051
|
+
async function login(reconnect = false) {
|
1044
1052
|
if (cookie) {
|
1045
|
-
log('login with cookie')
|
1053
|
+
log(reconnect ? 'reconnect with cookie' : 'login with cookie')
|
1046
1054
|
const newCookie = await loginWithCookie(cookie)
|
1047
1055
|
if (newCookie) {
|
1048
1056
|
cookie = newCookie
|
1049
1057
|
}
|
1050
1058
|
} else if (username && password) {
|
1051
|
-
log(`login with username ${username}`)
|
1059
|
+
log(reconnect ? `reconnect with username ${username}` : `login with username ${username}`)
|
1052
1060
|
steamClient.logOn({
|
1053
1061
|
accountName: username, password: password, rememberPassword: true, machineName: 'Natri',
|
1054
1062
|
})
|
1055
1063
|
}
|
1056
1064
|
}
|
1057
1065
|
|
1066
|
+
async function logOff() {
|
1067
|
+
isLogOff = true
|
1068
|
+
offAllEvent()
|
1069
|
+
doClearIntervals()
|
1070
|
+
steamClient.logOff()
|
1071
|
+
}
|
1072
|
+
|
1058
1073
|
function onCookie(callback) {
|
1059
1074
|
if(getCookies() ){
|
1060
1075
|
callback(getCookies())
|
@@ -1286,7 +1301,8 @@ function SteamClient({
|
|
1286
1301
|
isPrime(){
|
1287
1302
|
return prime === true
|
1288
1303
|
},
|
1289
|
-
getFriendList
|
1304
|
+
getFriendList,
|
1305
|
+
logOff,
|
1290
1306
|
}
|
1291
1307
|
}
|
1292
1308
|
|
package/index.js
CHANGED
@@ -2699,8 +2699,15 @@ class SteamUser {
|
|
2699
2699
|
}
|
2700
2700
|
|
2701
2701
|
//{ invited: [ '76561199277912057' ], success: 1 }
|
2702
|
-
|
2703
|
-
|
2702
|
+
/*
|
2703
|
+
* {
|
2704
|
+
failed_invites: [ '76561199227727116' ],
|
2705
|
+
failed_invites_result: [ 84 ],
|
2706
|
+
success: 1
|
2707
|
+
}
|
2708
|
+
* */
|
2709
|
+
async addFriendUser(steamID) {
|
2710
|
+
const {data} = await this._httpRequestAjax({
|
2704
2711
|
url: `actions/AddFriendAjax`,
|
2705
2712
|
data: {
|
2706
2713
|
steamid: steamID,
|
@@ -2712,6 +2719,21 @@ class SteamUser {
|
|
2712
2719
|
method: 'POST',
|
2713
2720
|
})
|
2714
2721
|
|
2722
|
+
if (data) {
|
2723
|
+
const failed_invites_result_message_mapping = {
|
2724
|
+
25: 'Could not invite %s. Your friends list is full.',
|
2725
|
+
15: 'Could not invite %s. Their friends list is full.',
|
2726
|
+
40: 'Error adding Friend. Communication between you and this user has been blocked.',
|
2727
|
+
11: 'You are blocking all communication with this user. Before communicating with this user, you must unblock them by visiting their Steam Community Profile.',
|
2728
|
+
84: `It looks like you've sent too many friend invites. To prevent spam, you'll have to wait before you can invite more friends. Please note that other players can still add you during this time.`,
|
2729
|
+
24: `Your account does not meet the requirements to use this feature. Visit Steam Support for more information.`,
|
2730
|
+
}
|
2731
|
+
const failed_invites_result = data?.failed_invites_result?.[0]
|
2732
|
+
if (failed_invites_result && failed_invites_result_message_mapping[failed_invites_result]) {
|
2733
|
+
data.failed_invites_result_message = failed_invites_result_message_mapping[failed_invites_result]
|
2734
|
+
}
|
2735
|
+
}
|
2736
|
+
|
2715
2737
|
return data
|
2716
2738
|
}
|
2717
2739
|
|
@@ -3222,7 +3244,7 @@ class SteamUser {
|
|
3222
3244
|
FriendsPreviously: [],//Friends who have played Counter-Strike: Global Offensive previously _
|
3223
3245
|
FriendsAddedLibrary: [],//Friends who have Counter-Strike: Global Offensive in their library _
|
3224
3246
|
}
|
3225
|
-
if (!result
|
3247
|
+
if (!result?.data) {
|
3226
3248
|
return data
|
3227
3249
|
}
|
3228
3250
|
const $ = result._$()
|
package/package.json
CHANGED