-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (29 loc) · 1.1 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
const SteamUser = require('steam-user')
const { Logger } = require('betterlogger.js')
const qrcode = require('qrcode-terminal')
const { LoginSession, EAuthTokenPlatformType } = require('steam-session')
const client = new SteamUser()
const logger = new Logger('Steam Idle').setDebugging(99)
client.on('loggedOn', () => {
logger.log(`Logged in as ${client.steamID.getSteam2RenderedID()}`)
client.setPersona(SteamUser.EPersonaState.Online)
client.gamesPlayed([730])
})
const init = async () => {
const session = new LoginSession(EAuthTokenPlatformType.SteamClient)
const startResult = await session.startWithQR()
qrcode.generate(startResult.qrChallengeUrl, { small: true })
session.on('remoteInteraction', () => {
logger.log("Looks like you've scanned the code! Now just approve the login.")
})
session.on('timeout', () => {
logger.error('The login session has timed out.')
})
session.on('error', err => {
logger.error('An error occurred while trying to login:', err)
})
session.on('authenticated', async () => {
client.logOn({ refreshToken: session.refreshToken })
})
}
init()