Hello guys. I've got a problem which i cant decide by myself.. First problem was that my bot was going offline with no reason, but i decided it And now i got the second problem: After few hours (sometimes days) bot asking for steam guard code. In console it looks like: "Steam Guard Code:". Guys, need your help Thanks. Code:
const config = require("./config.js");
const Config = require('config-js');
const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const SteamCommunity = require('steamcommunity');
const TradeofferManager = require('steam-tradeoffer-manager');
const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeofferManager({
steam: client,
community: community,
language: 'en' // Может быть любой язык
});
// Log in to account with config.js
const logOnOptions = {
"accountName": config.steam.username,
"password": config.steam.password,
"twoFactorCode": SteamTotp.generateAuthCode(config.steam.twoFactorCode)
};
client.logOn(logOnOptions);
// After success login
client.on('loggedOn', () => {
console.log('Bot succesfully authorized!');
client.setPersona(SteamUser.Steam.EPersonaState.Online, config.steam.botname);
console.log('Bot status changed to "Online"');
});
// Thats how i solve problem with going offline
community.on('sessionExpired', function(err) {
if (err) {
console.log('sessionExpired: '+err);
}
community.stopConfirmationChecker();
if (client.steamID) {
client.webLogOn();
} else {
client.logOn(logOnOptions);
}
});
// Thats my way to solve second problem, but it didnt help.
client.on("steamGuard", function(domain, callback, lastCodeWrong) {
if(lastCodeWrong) {
console.log("Last code wrong, try again!");
setTimeout(function() {
callback(SteamTotp.getAuthCode(config.steam.twoFactorCode));
}, 30000);
}
});