Jump to content
McKay Development

Meiki

Member
  • Posts

    3
  • Joined

  • Last visited

Meiki's Achievements

  1. 1. I am using the latest version of "steam-user", 4.25.0 2. Yes, this is a better implementation, thank you 3. Tried to do this, but now every time at the first run of checkOnline() instead of nonexisting data I receive timeouts, one per every receiver, at the second run everything is fine again. So, I guess, I`ll stuck with setTimeout(). Example of code: client.on('loggedOn', function () { console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID()); client.setPersona(SteamUser.EPersonaState.Online) client.on('user', function (sid, user) { // should be enough because Steam emits it only if this client instance's persona state is online if (Object.values(user).includes('link-to-bot-profile-picture.jpg')) { checkOnline() } }) }); Example of timeout: Error: Request timed out at Timeout._onTimeout (C:\Users\Andrew\WebstormProjects\Notif-steam-bot\node_modules\@doctormckay\stdlib\components\promises.js:17:12) at listOnTimeout (node:internal/timers:559:17) at processTimers (node:internal/timers:502:7)
  2. 1. That`s the funny thing, I don`t understand why, but when personas is before err, it is just logging into console all the data instead of errors, like: { '22222222222222222': { rich_presence: [], persona_state: 3, game_played_app_id: 0, ...etc } } The only way it works correctly in this order is like this, the problem still persists : client.getPersonas([receivers[i]], function (personas, err) { if (personas) { console.log(personas) } else { let data = err[receivers[i]].persona_state 2. Actually in the real code I am fetching data row by row from sqlite database, checking for each row a column wasMessagedToday, if it is false, then calling getPersonas() and if messaged successfully, updating wasMessagedToday value in database to true. Maybe there is a better way, but I am an absolute newbie in database stuff. 3. Thank you, thank you!!! I`ve tried already few ways to delay time including setTimeout(checkOnline, 2000) after setting persona to Online, but it wasn`t working. Tried now to increase the delay to 10 seconds and now data from getPersonas() is correct at every run! I guess Steam is really slow with status updates. So the fix looks like this: client.on('loggedOn', function () { console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID()); client.setPersona(SteamUser.EPersonaState.Online) setTimeout(checkOnline, 10000); });
  3. I am trying to create a program, which every specified ammount of time sends a message to my steam friends, if conditions are met. The thing is that I call messaging function after setting bot status to Online, but at the first run client.getPersonas() returns all the users data, like the bot`s persona is offline (most parameters are null or 0). Everything works fine at second and subsequent runs of checkOnline(). Please, I am almost sure this is because of some stupid mistake, but I cannot find this mistake for two days already. Please tell me, where I messed up. Simplified code below. steam-user v4.25.0 import SteamUser from "steam-user"; import SteamTotp from "steam-totp"; const receivers = [ '11111111111111111', //IDs for example '22222222222222222', ] function main() { const client = new SteamUser(); function steamLogin() { client.logOn({ "accountName": process.env.accountName, "password": process.env.password, twoFactorCode: SteamTotp.generateAuthCode(process.env.twoFactorCode) }); client.on('loggedOn', function () { console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID()); client.setPersona(SteamUser.EPersonaState.Online) checkOnline() //calling the second function }); } function checkOnline() { for (let i = 0; i < receivers.length; i++) { client.getPersonas([receivers[i]], function (personas, err) { if (err) { console.log(err) } else { let data = personas[receivers[i]].persona_state if (data === 1 || data === 2 || data === 3) { client.chat.sendFriendMessage(receivers[i], `It works!`); console.log('Message sent!', receivers[i]) } } }) } setTimeout(checkOnline, 10000); } steamLogin() } main()
×
×
  • Create New...