For some reason, offers are not processed by the bot, neither newOffer nor pollData is processed. Although the bot is successfully launched and cookies are installed, as far as I can tell from the logs, but for some reason the offers do not come, I send them manually to the bot.
I was reading this form looking for answers, and I found some advice that when working with CS:GO items should use useAccessToken, but it didn't help.
The bot also parses inventory and gets prices for items at this time, sometimes I exceed the number of requests and get 429 responses, could this be a problem?
Logs:
{
"logs": [
{
"id": 15023,
"message": "success polling data",
"time": "2025-02-21 15:24:45.830",
"body": null,
"status": "success",
"error": null
},
{
"id": 15016,
"message": "success polling data",
"time": "2025-02-21 15:24:15.596",
"body": null,
"status": "success",
"error": null
},
{
"id": 15017,
"message": "polling data",
"time": "2025-02-21 15:24:15.596",
"body": "{\"data\":{\"sent\":{},\"received\":{},\"timestamps\":{},\"offersSince\":0}}",
"status": "test",
"error": null
},
{
"id": 15014,
"message": "Session is valid",
"time": "2025-02-21 15:24:15.305",
"body": "secret",
"status": "success",
"error": null
},
{
"id": 15013,
"message": "TradeOfferManager set up with current cookies.",
"time": "2025-02-21 15:24:15.279",
"body": "secret"
"status": "success",
"error": null
},
{
"id": 15012,
"message": "Cookies set up",
"time": "2025-02-21 15:24:14.858",
"body": "secret",
"status": "success",
"error": null
},
{
"id": 15011,
"message": "Starting cookie setup",
"time": "2025-02-21 15:24:14.779",
"body": "secret",
"status": "test",
"error": null
},
{
"id": 15010,
"message": "Bot <botname> logged in. Steam Id: <steamid>",
"time": "2025-02-21 15:24:14.368",
"body": "secret"
"status": "success",
"error": null
},
{
"id": 15009,
"message": "logged on",
"time": "2025-02-21 15:24:12.227",
"body": "secret",
"status": "success",
"error": null
}
]
}
Bot code(I removed all the logic and left only logs) :
import SteamTotp from 'steam-totp';
import TradeOfferManager from 'steam-tradeoffer-manager';
import SteamUser from 'steam-user';
import SteamCommunity from 'steamcommunity';
import '../extensions/extensions.js';
import logsService from '../services/logsService.js';
export class Bot {
steamID;
config;
client;
community;
manager;
constructor(config, checkDelay) {
this.config = config;
this.client = new SteamUser();
this.community = new SteamCommunity();
this.manager = new TradeOfferManager({
steam: this.client,
community: this.community,
language: 'en',
useAccessToken: true,
});
this.logOn();
this.client.on('disconnected', (err, msg) => {
logsService.logError('Bot logged out, session invalid', {
err,
msg,
});
});
this.client.on('error', (err) => {
logsService.logError('Error during bot work', {}, err);
});
this.client.on('loggedOn', async (details) => {
this.steamID = details.client_supplied_steamid;
logsService.logSuccess(
`Bot ${config.username} logged in. Steam Id: ${details.client_supplied_steamid}`,
{ details },
);
this.client.gamesPlayed(730);
if (config.isNeedToLogSteamGuard) {
setInterval(() => {
logsService.logTest(
`Bot "${config.username}". Steam Guard: ${SteamTotp.generateAuthCode(config.shared_secret)}`,
);
}, config.refreshInterval);
}
});
this.client.on('webSession', async (sessionId, cookies) => {
logsService.logTest('Starting cookie setup', { cookie: cookies });
this.manager.setCookies(cookies, (err) => {
if (err) {
logsService.logError(
`Error setting up TradeOfferManager: ${err}`,
cookies,
err,
);
} else {
logsService.logSuccess(
'TradeOfferManager set up with current cookies.',
cookies,
);
}
});
this.community.setCookies(cookies);
this.community.startConfirmationChecker(
config.refreshInterval,
config.identity_secret,
);
logsService.logSuccess('Cookies set up', cookies);
this.community.getSteamUser(this.community.steamID, (err, user) => {
if (err) {
logsService.logError(
'Session check error, cookies may be invalid',
{},
err,
);
} else {
logsService.logSuccess('Session is valid', { user });
}
});
});
this.manager.on('sentOfferChanged', (offer, oldState) => {
logsService.logTest('sentOfferChanged', { offer });
});
this.manager.on('newOffer', (offer) => {
logsService.logTest('offer received', {
offer,
isAdmin,
admin_steam_id: +process.env.ADMIN_STEAM_ID,
});
});
this.manager.on('pollData', (data) => {
logsService.logTest('polling data', { data });
});
this.manager.on('pollFailure', (err) => {
logsService.logError('error polling data', {}, err);
});
this.manager.on('pollSuccess', (data) => {
logsService.logSuccess('success polling data', data);
});
}
async logOn() {
const logOnOptions = {
accountName: this.config.username,
password: this.config.password,
twoFactorCode: SteamTotp.generateAuthCode(this.config.shared_secret),
autoRelogin: true,
};
this.client.logOn(logOnOptions);
logsService.logSuccess('logged on', { logOnOptions });
}
}