Jump to content


Photo

BREAKING CHANGES: steam-user v4 now available on npm

node.js node-steam-user

  • Please log in to reply
41 replies to this topic

#21 byteframe

byteframe

    Member

  • Member
  • PipPip
  • 25 posts

Posted 28 January 2019 - 09:05 PM

Oh ok, I thought it was going to be a situation like before whereby the 'old webchat' was available in steam-community, ehh, because it was 'web based'. 



#22 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 30 January 2019 - 12:43 AM

v4 is now out of beta and is live on npm.



#23 byteframe

byteframe

    Member

  • Member
  • PipPip
  • 25 posts

Posted 31 January 2019 - 12:15 PM

huzzahs are in order.


  • Dr. McKay likes this

#24 PonyExpress

PonyExpress

    Advanced Member

  • Member
  • PipPipPip
  • 31 posts

Posted 02 February 2019 - 07:55 AM

I Trying to learn new features and I ran into several questions.

 

1:

chatMessage(recipient, message[, type]) -- This is deprecated. You should use SteamChatRoomClient instead, which is available as the chat property of each SteamUser instance.‚Äč

I'm currently using:

client.on("friendMessage", (SENDER, MSG) => {
//...
});

Should I use something else and what benefits will it give?

I tried something like this, but it looks like I make a mistake:
client.on("chat", (SENDER, MSG) => {
client.chat.on("friendMessage", (SENDER, MSG) => {

 

2:

I can not understand what is "chat" and why it is necessary, where you can use it

// old:
client.chatMessage(SENDER, "bot say...");
// new:
client.chat.sendFriendMessage(SENDER, "bot say...");


#25 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 02 February 2019 - 07:57 PM

client.chat.on("friendMessage", (SENDER, MSG) => { is the correct one to use.

 

It felt to me that having every method attached directly to SteamUser was getting kind of messy, so for v4 and new Steam chat I opted to create a separate "handler class" and attach it to SteamUser for interacting with new Steam chat. You can read the docs for new Steam chat here. Just remember that to use any method or event on that page, you need to use client.chat.methodName() or client.chat.on('eventName').



#26 furi

furi

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 02 February 2019 - 10:19 PM

In my code i use only logOn method and event listeners such as loggedOn and webSession. Is it normal?

Attached Files


Edited by Dr. McKay, 02 February 2019 - 11:54 PM.
Uploaded image

  • Royalgamer06 likes this

#27 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 02 February 2019 - 11:58 PM

Is that happening consistently? If so, can you show what code you're using?



#28 furi

furi

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 03 February 2019 - 01:34 AM

Is that happening consistently? If so, can you show what code you're using?

it happened once on 2 of 4 my bots during recent problems with steam

const SteamCommunity = require('steamcommunity');
const SteamUser = require('steam-user');
const TradeOfferManager = require('steam-tradeoffer-manager');
const steamTotp = require('steam-totp');

const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager({ community });

let isAlive = false;
const DEFAULT_TIMER = 60 * 1000;

client.logOn(logInOptions);

client.on('loggedOn', () => {
  log('Steam client loggedOn okay');
  client.setPersona(1);
});

client.on('webSession', (sessionid, cookies) => {
  manager.setCookies(cookies, err => {
    if (err) return log(`Steam coockies: ${err}`);
    isAlive = true;
    log('Steam webSession okay');
  });
});

community.on('sessionExpired', err => {
  setTimeout(steamCommunityLogin, DEFAULT_TIMER);
  isAlive = false;
  log(`Steam community session: ${err}`);
});

client.on('error', err => log(`Steam client: ${err}`));

function steamCommunityLogin() {
  if (!isAlive) {
    community.login({ ...logInOptions, twoFactorCode: steamTotp.getAuthCode(sharedSecret) }, err => {
      if (err) {
        setTimeout(steamCommunityLogin, DEFAULT_TIMER);
        log(`Steam community login: ${err}`);
      } else {
        isAlive = true;
        log('Steam community login okay');
      }
    });
  }
}


#29 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 03 February 2019 - 04:40 AM

  1. Do you think you could possibly add: client.on('debug', log); This will help to narrow down what's going on if it happens again.
  2. You don't need to login through SteamCommunity if your session expires. Just call client.webLogOn() in that case.


#30 furi

furi

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 03 February 2019 - 05:51 AM

 

  1. Do you think you could possibly add: client.on('debug', log); This will help to narrow down what's going on if it happens again.
  2. You don't need to login through SteamCommunity if your session expires. Just call client.webLogOn() in that case.

 

1. ok, i add this and if this will repeat, i'll report here
2. yeah, actually, thanks


Edited by furi, 03 February 2019 - 05:54 AM.


#31 furi

furi

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 05 February 2019 - 10:53 PM

another error

/root/bot/node_modules/steam-user/components/connection.js:21
        this._connection.stream.setTimeout(0);
                                ^
 
TypeError: Cannot read property 'setTimeout' of undefined
    at SteamUser.<anonymous> (/root/bot/node_modules/steam-user/components/connection.js:21:26)
    at handlers.forEach (/root/bot/node_modules/steam-user/components/classes/HandlerManager.js:37:12)
    at Array.forEach (<anonymous>)
    at HandlerManager.emit (/root/bot/node_modules/steam-user/components/classes/HandlerManager.js:36:12)
    at SteamUser._handleMessage (/root/bot/node_modules/steam-user/components/messages.js:538:24)
    at SteamUser._handleNetMessage (/root/bot/node_modules/steam-user/components/messages.js:464:7)
    at TCPConnection._readMessage (/root/bot/node_modules/steam-user/components/connection_protocols/tcp.js:193:12)
    at Socket.emit (events.js:182:13)
    at emitReadable_ (_stream_readable.js:534:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

last 2 minute debug, in 23:40:45 was crash

[Tue, 05 Feb 2019 23:38:21 GMT] Steam debug: Unhandled message: 850
[Tue, 05 Feb 2019 23:39:45 GMT] Steam debug: Handled message: 5599
[Tue, 05 Feb 2019 23:40:15 GMT] Steam debug: Handled message: 5599
[Tue, 05 Feb 2019 23:40:39 GMT] Steam debug: Handled message: 757
[Tue, 05 Feb 2019 23:40:39 GMT] Steam debug: Logged off: ServiceUnavailable
[Tue, 05 Feb 2019 23:40:40 GMT] Steam debug: Using WebSocket; we rolled 47 and percent to use WS is 50
[Tue, 05 Feb 2019 23:40:41 GMT] Steam debug: WebSocket disconnected with error: read ECONNRESET
[Tue, 05 Feb 2019 23:40:41 GMT] Steam debug: Using WebSocket; we rolled 47 and percent to use WS is 50
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: WS connection timed out
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Using TCP; we rolled 93 and percent to use WS is 50
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Connecting to TCP CM: *some IP*
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: WebSocket disconnected with error: read ECONNRESET
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Using TCP; we rolled 64 and percent to use WS is 50
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Connecting to TCP CM: *another IP*
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: TCP connection established
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Handled message: 1303
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Channel encrypt request: protocol 1, universe 1, nonce *some ID*, 0 remaining bytes
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Sending message: 1304
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Handled message: 1305
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Sending message: 5514
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Handled message: 751
[Tue, 05 Feb 2019 23:40:42 GMT] Steam debug: Log on response: TryAnotherCM
[Tue, 05 Feb 2019 23:40:43 GMT] Steam debug: TCP connection established
[Tue, 05 Feb 2019 23:40:43 GMT] Steam debug: Using WebSocket; we rolled 11 and percent to use WS is 50
[Tue, 05 Feb 2019 23:40:44 GMT] Steam debug: Handled message: 1303



#32 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 06 February 2019 - 01:05 PM

The next update will hopefully fix this.



#33 Ino

Ino

    Advanced Member

  • Member
  • PipPipPip
  • 83 posts

Posted 09 February 2019 - 07:45 AM

The next update will hopefully fix this.

Hello, i found a new bug. When set offline or invisible state through steam chat or method setPersona - event user emitted with persona_state 3 (Away) instead of persona_state 0 (offline)


Edited by Ino, 09 February 2019 - 09:00 AM.


#34 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 09 February 2019 - 03:28 PM

Hello, i found a new bug. When set offline or invisible state through steam chat or method setPersona - event user emitted with persona_state 3 (Away) instead of persona_state 0 (offline)

 

Assuming this is happening like you describe, that would be a problem with Steam, not with this module.

 

But what I suspect is happening is that you're logged into that same account with another bot (or with the Steam client) and its persona state is away. If any logged-on session is in an online state (anything but invisible/offline), the account will show up as that state.



#35 byteframe

byteframe

    Member

  • Member
  • PipPip
  • 25 posts

Posted 14 February 2019 - 04:05 PM

What is the recommendation for listening to chat events? Should we switch to watching the events from the new chat component, or are the older events sufficient?



#36 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,162 posts

Posted 25 February 2019 - 04:49 AM

What is the recommendation for listening to chat events? Should we switch to watching the events from the new chat component, or are the older events sufficient?

 

The older events are deprecated, but they will keep working until at least v5. Though I recommend switching to the new events.



#37 Royalgamer06

Royalgamer06

    Advanced Member

  • Member
  • PipPipPip
  • 94 posts

Posted 03 March 2019 - 05:37 PM

Something weird is happening. I updated my bot to work with your latest steam packages. However, sometimes it seems like something inside steam-user gets stuck. Sometimes it works just fine, but other time it will only emit loggedOn and websession events. All other events are not emitted. And that's not all. I expect loggedOn to be only emitted once, since in my code I only login once, however when these other events are not emitted, loggedOn gets emitted every 2 minutes. Any idea what's going on?


Edited by Royalgamer06, 03 March 2019 - 05:38 PM.


#38 Royalgamer06

Royalgamer06

    Advanced Member

  • Member
  • PipPipPip
  • 94 posts

Posted 03 March 2019 - 05:51 PM

I've made it log all debug events and this is the log: https://pastebin.com/EZRG8xm3

It repeats every 2 minutes, until it finally works. Sometimes it works at first try, but often it takes several tries. 

loggedOnSteam only gets logged on loggedOn event. And signedIntoBarter only gets logged ONCE websession.

This is my login config (un and pass omitted)

{ accountName: 'xxx',
  password: 'xxx',
  twoFactorCode: 'XXX',
  logonID: 1551653434369,
  rememberPassword: true,
  dontRememberMachine: false,
  autoRelogin: true,

  machineName: '[email protected]' }: 

 

WebSocket disconnected with error: Ping timeout

This seems to cause it, or at least be related with it.


Edited by Royalgamer06, 03 March 2019 - 05:53 PM.


#39 Royalgamer06

Royalgamer06

    Advanced Member

  • Member
  • PipPipPip
  • 94 posts

Posted 03 March 2019 - 06:19 PM

Another issue getProductInfo callback doesn't get fired. 



#40 Royalgamer06

Royalgamer06

    Advanced Member

  • Member
  • PipPipPip
  • 94 posts

Posted 04 March 2019 - 01:56 PM

Another issue getProductInfo callback doesn't get fired. 

This issue isn't specific to v4. I can't get it to work on the latest version of v3 either. Debugging this currently...







Also tagged with one or more of these keywords: node.js, node-steam-user

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users