steamutils 1.0.34 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SteamClient.js +32 -9
- package/package.json +2 -1
package/SteamClient.js
CHANGED
@@ -9,6 +9,7 @@ import helpers from "./helpers/protos.js";
|
|
9
9
|
import {fileURLToPath} from "url";
|
10
10
|
import path from "path";
|
11
11
|
import SteamUtils from "./index.js";
|
12
|
+
import {v4 as uuidv4} from 'uuid';
|
12
13
|
|
13
14
|
const __filename = fileURLToPath(import.meta.url);
|
14
15
|
const __dirname = path.dirname(__filename);
|
@@ -99,7 +100,27 @@ function SteamClient({
|
|
99
100
|
friendTyping: [],
|
100
101
|
}
|
101
102
|
|
102
|
-
const intervals =
|
103
|
+
const intervals = {}
|
104
|
+
|
105
|
+
function doSetInterval(cb, timeout, key) {
|
106
|
+
if (!key) {
|
107
|
+
key = uuidv4()
|
108
|
+
}
|
109
|
+
if (intervals[key] !== undefined) {
|
110
|
+
try {
|
111
|
+
clearInterval(intervals[key])
|
112
|
+
} catch (e) {
|
113
|
+
}
|
114
|
+
}
|
115
|
+
intervals[key] = setInterval(cb, timeout)
|
116
|
+
}
|
117
|
+
|
118
|
+
function doClearIntervals() {
|
119
|
+
for (const key in intervals) {
|
120
|
+
clearInterval(intervals[key])
|
121
|
+
delete intervals[key]
|
122
|
+
}
|
123
|
+
}
|
103
124
|
|
104
125
|
function getAccountInfoName() {
|
105
126
|
return [steamClient?.accountInfo?.name, steamClient?._logOnDetails?.account_name].filter(Boolean).join(" - ")
|
@@ -163,7 +184,10 @@ function SteamClient({
|
|
163
184
|
* @returns {Promise.<Object>}
|
164
185
|
*/
|
165
186
|
async function partySearch({
|
166
|
-
prime = false,
|
187
|
+
prime = false,
|
188
|
+
game_type = 'Competitive',
|
189
|
+
rank = 'Silver Elite',
|
190
|
+
timeout = 10000,
|
167
191
|
}) {
|
168
192
|
|
169
193
|
return new Promise(resolve => {
|
@@ -176,7 +200,7 @@ function SteamClient({
|
|
176
200
|
game_type: game_type === 'Competitive' ? 8 : 10
|
177
201
|
}))
|
178
202
|
partySearchCallback.push(resolve)
|
179
|
-
setTimeout(resolve,
|
203
|
+
setTimeout(resolve, timeout)
|
180
204
|
})
|
181
205
|
}
|
182
206
|
|
@@ -202,7 +226,7 @@ function SteamClient({
|
|
202
226
|
function bindEvent() {
|
203
227
|
steamClient.on('disconnected', async (eresult, msg) => {
|
204
228
|
console.log('disconnected', eresult, msg)
|
205
|
-
|
229
|
+
doClearIntervals()
|
206
230
|
})
|
207
231
|
steamClient.on('error', async (e) => {
|
208
232
|
let errorStr = ``
|
@@ -225,7 +249,7 @@ function SteamClient({
|
|
225
249
|
break
|
226
250
|
}
|
227
251
|
console.log('error', e?.message)
|
228
|
-
|
252
|
+
doClearIntervals()
|
229
253
|
})
|
230
254
|
|
231
255
|
steamClient.on('webSession', (sessionID, cookies) => {
|
@@ -790,10 +814,9 @@ function SteamClient({
|
|
790
814
|
getPlayersProfile,
|
791
815
|
autoRequestFreeLicense,
|
792
816
|
playCSGO,
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
async gamesPlayed(apps){
|
817
|
+
doSetInterval,
|
818
|
+
doClearIntervals,
|
819
|
+
async gamesPlayed(apps) {
|
797
820
|
steamClient.gamesPlayed(apps);
|
798
821
|
await sleep(2000)
|
799
822
|
steamClient.setPersona(SteamUser.EPersonaState.LookingToPlay)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "steamutils",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.36",
|
4
4
|
"dependencies": {
|
5
5
|
"axios": "^1.3.4",
|
6
6
|
"cheerio": "^1.0.0-rc.12",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"steam-user": "^4.28.1",
|
13
13
|
"steamid": "^2.0.0",
|
14
14
|
"url-parse": "^1.5.10",
|
15
|
+
"uuid": "^9.0.0",
|
15
16
|
"xml-js": "^1.6.11",
|
16
17
|
"xml2js": "^0.4.23"
|
17
18
|
},
|