Jump to content


Photo
Question

getPersonas 'Persona Name'

node.js node-steam-user

  • Please log in to reply
9 replies to this topic

#1 THR

THR

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 07 March 2019 - 09:24 AM

Hello,

I just started building my steam level up bot and couldn't code it when someone adding him to tell 'Hello, "Persona Name" Thank you for adding me'.

this is the code i put it from another question but its sending 'Hello, [SteamID] Thank you for adding me'.

    client.getPersonas([steamID], function(personas) {
    var persona = personas[steamID.getSteamID64()];
    var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]");
    });    
 
    
 
    client.chatMessage(steamID, 'Hi ' + name + ' Thank you for adding me!');
  }
  });


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,140 posts

Posted 07 March 2019 - 06:31 PM

What version of steam-user are you using?



#3 THR

THR

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 08 March 2019 - 08:17 AM

[email protected] i get the information from the package.json.

Now i change it to 4.5 but the same it sending the SteamID not the the name.


Edited by THR, 08 March 2019 - 08:33 AM.


#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,140 posts

Posted 08 March 2019 - 11:05 PM

Please read the v4 release notes. The first argument to callbacks is now err.



#5 THR

THR

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 09 March 2019 - 11:35 AM

Can you tell me how to callback the err,please ?



#6 THR

THR

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 09 March 2019 - 11:48 AM

OK sir it worked and this is the code.Please tell me if there is any mistake and thank you.

    client.getPersonas([steamID], function(err, personas) {
    if (err) {console.log('error.')}
    else {
    persona = personas[steamID.getSteamID64()];
    name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]");
 
    client.chatMessage(steamID,'The name is ' + name);
    }


#7 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,140 posts

Posted 09 March 2019 - 10:06 PM

Yep, that looks correct. I'm pretty curious as to how you weren't crashing with the old code, but as long as that works, all's well that ends well.



#8 THR

THR

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 10 March 2019 - 02:53 PM

Thank you anyway sir. I just wanted to ask you about steamcommunity postUserComment here is the code : 

 

client.on('friendRelationship', (steamID, relationship) => {
if (relationship === SteamUser.EFriendRelationship.RequestRecipient) {
    client.addFriend(steamID);
    client.inviteToGroup(steamID, config.groupid, );
    
    community.postUserComment(steamID, "Thanks for adding me ! I wish you good day.");
 
it is doing nothing, can you tell me how to callback ??
Please help me it's not working

Edited by THR, 11 March 2019 - 01:33 PM.


#9 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,140 posts

Posted 11 March 2019 - 02:47 PM

You might need to wait for friendRelationship to get emitted again with relationship SteamUser.EFriendRelationship.Friend. But a lot of people are having issues automatically posting comments; Valve might have put some anti-spam measures into place.



#10 CellSplitter

CellSplitter

    Member

  • Member
  • PipPip
  • 20 posts

Posted 04 April 2019 - 08:16 AM

You can do this for example:

client.on('friendRelationship', function(steamID, relationship) {
if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipient) {
client.addFriend(steamID);
console.log(" ");
console.log("Accepted friend request from: " + steamID);
var name;
client.getPersonas([steamID], function(personas) {
var persona = personas[steamID];
name = persona ? persona.player_name : ("[" + steamID + "]");
client.chatMessage(steamID, "\nWelcome " + name + " !!!" +
"\nI am a +REP BOT and i can give you a +REP Comment on your SteamĀ® Profile" +
"\nType !help in Chat to get started!"
);
});

}
});





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

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users