steamutils 1.0.34 → 1.0.35
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 +25 -6
- 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,26 @@ function SteamClient({
|
|
99
100
|
friendTyping: [],
|
100
101
|
}
|
101
102
|
|
102
|
-
const intervals =
|
103
|
+
const intervals = {}
|
104
|
+
function doSetInterval(cb, timeout, key) {
|
105
|
+
if(!key){
|
106
|
+
key = uuidv4()
|
107
|
+
}
|
108
|
+
if (intervals[key] !== undefined) {
|
109
|
+
try {
|
110
|
+
clearInterval(intervals[key])
|
111
|
+
} catch (e) {
|
112
|
+
}
|
113
|
+
}
|
114
|
+
intervals[key] = setInterval(cb, timeout)
|
115
|
+
}
|
116
|
+
|
117
|
+
function doClearIntervals() {
|
118
|
+
for (const key in intervals) {
|
119
|
+
clearInterval(intervals[key])
|
120
|
+
delete intervals[key]
|
121
|
+
}
|
122
|
+
}
|
103
123
|
|
104
124
|
function getAccountInfoName() {
|
105
125
|
return [steamClient?.accountInfo?.name, steamClient?._logOnDetails?.account_name].filter(Boolean).join(" - ")
|
@@ -202,7 +222,7 @@ function SteamClient({
|
|
202
222
|
function bindEvent() {
|
203
223
|
steamClient.on('disconnected', async (eresult, msg) => {
|
204
224
|
console.log('disconnected', eresult, msg)
|
205
|
-
|
225
|
+
doClearIntervals()
|
206
226
|
})
|
207
227
|
steamClient.on('error', async (e) => {
|
208
228
|
let errorStr = ``
|
@@ -225,7 +245,7 @@ function SteamClient({
|
|
225
245
|
break
|
226
246
|
}
|
227
247
|
console.log('error', e?.message)
|
228
|
-
|
248
|
+
doClearIntervals()
|
229
249
|
})
|
230
250
|
|
231
251
|
steamClient.on('webSession', (sessionID, cookies) => {
|
@@ -790,9 +810,8 @@ function SteamClient({
|
|
790
810
|
getPlayersProfile,
|
791
811
|
autoRequestFreeLicense,
|
792
812
|
playCSGO,
|
793
|
-
|
794
|
-
|
795
|
-
},
|
813
|
+
doSetInterval,
|
814
|
+
doClearIntervals,
|
796
815
|
async gamesPlayed(apps){
|
797
816
|
steamClient.gamesPlayed(apps);
|
798
817
|
await sleep(2000)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "steamutils",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.35",
|
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
|
},
|