Jump to content
McKay Development

how can I get the nickname when I receive a message from some steam friend?


Recommended Posts

Posted

Hello, I am really new to this and I would very much appreciate you helping me, I already have time looking at the github but it confuses me since there are no examples, my question is how can I get the nickname when I receive a message from some steam friend?

look they use getpersona but always sends me mistakes :( 

I had already left this behind but the truth is that I am not satisfied

I just want to be able to do something like...

[automatic message] Hello "nickname", I am currently resting blablabla

Posted

D:\bot\bot.js:75
    var persona = personas[steamID.getSteamID64()];
                                           ^

TypeError: Cannot read property '76561198987247955' of null
    at D:\bot\bot.js:75:27
    at Immediate.<anonymous> (D:\bot\node_modules\steam-user\node_modules\@doctormckay\stdlib\components\promises.js:90:6)
    at processImmediate (internal/timers.js:461:21)

 

Posted

I think I am using the latest version since I just installed the module

const SteamUser = require('steam-user');
const config = require('./config.json');
const client = new SteamUser();



const logOnOptions = {
	accountName: config.username, 
	password: config.password
};

client.logOn(logOnOptions);

client.on('loggedOn', () => {
	//mensaje cuando se logra iniciar sesion
	console.log('Entraste a Steam :)');
	console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID() + " /// ");
  	//ponerse el estado En Linea
  	client.setPersona(SteamUser.EPersonaState.Online);
  	//ponerse un juego por ID de juego
  	client.gamesPlayed(753); 
  //cambiarse nombre
  //client.setPersona(SteamUser.EPersonaState.Online, 'Nuevo nombre')
  // "̷̢̧̐͂̾ͤͭƝ҉o҉i҉s҉e"
  //client.gamesPlayed(["Custom Game", "̷̢̧̐͂̾ͤͭƝ҉o҉i҉s҉e"]);
  //client.gamesPlayed(["Custom Game", "Mentira si es de stim"]);
  /* ________________________________________________________________________________
  	setTimeout(function(){
  	if (flag == true) 
  	{
  		flag = false;
  		client.gamesPlayed(753);
  		console.log("Cambio a STEAM,  flag now is false");
  	}else
  	{
  		flag = true;
  		client.gamesPlayed(["Custom Game", "̷̢̧̐͂̾ͤͭƝ҉o҉i҉s҉e"]);
  		console.log("Cambio a Noise,  flag now is true");
  	}
  },10000);
  ______________________________________________________________________________________
  */

//Practicamente esto es un TIMER como en c#  solo que este ya tiene el Enable = true;
 /* ______________________________________________________________________________________
 	var cambiarestado = function(){
  	if (flag == true) 
  	{
  		flag = false;
  		client.gamesPlayed(753);
  		console.log("Cambio a STEAM,  flag now is false");
  	}else
  	{
  		flag = true;
  		client.gamesPlayed(["Custom Game", "̷̢̧̐͂̾ͤͭƝ҉o҉i҉s҉e"]);
  		console.log("Cambio a Noise,  flag now is true");
  	}

  	setTimeout(cambiarestado, 10000);
  }
  cambiarestado();
  ______________________________________________________________________________________
  */
});
//cuenta los items nuevos in mi inventario
client.on('newItems', function(count){
	console.log(count +" nuevos items in tu inventario");
});

client.on('wallet', function(hasWallet, currency, balance){
	console.log("Tu balance en la cartera es "+SteamUser.formatCurrency(balance, currency));
});
		
client.on("friendMessage", function(steamID, message) {
	client.getPersonas([steamID], function(personas) {
    var persona = personas[steamID.getSteamID64()]; 
    var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]");
    // the player's name is now available as name
	});
	
	if (message == "!play steam") {
		client.chatMessage(steamID,"jugando STEAM ");
		client.gamesPlayed(753);
	}
	else
	if (message == "!play gtav") {
		client.chatMessage(steamID,"jugando GTA V ");
		client.gamesPlayed(271590);
	}
	else
	if (message == "!play l4d2") {
		client.chatMessage(steamID,"jugando Left 4 Dead 2");
		client.gamesPlayed(550);
	}else
	if (message == "!play online") {
		client.chatMessage(steamID,"Online");
		client.gamesPlayed(0);
	}else
	if (message == "!info") {
			client.chatMessage(steamID, "https://steamcommunity.com/profiles/"+steamID+"/ Hola , Soy el asistente de ̷̷̢̧̢̧̐͂̾ͤͭ̐͂̾ͤͭƝ҉o҉i҉s҉e, ahora mismo no se encuentra disponible, seguramente se está haciendo una eterna ;D ó mirando sus monas chinas.");
			client.chatMessage(steamID,"/sticker Excited");
			client.chatMessage(steamID, "Regresa pronto o deja tu mensaje para que pueda leerlo cuando esté disponible, Escucha ésto: https://www.youtube.com/watch?v=LACbVhgtx9I");
	}else
	if (message == "!eliminar"){
		client.chatMessage(steamID, "Bye :demoticon:");
		client.removeFriend(steamID);
	}else
	{


		
		/*steamUser.getPersonas(["76561198155468977"], function (data) { console.log(data) });*/
		client.chatMessage(steamID,"https://steamcommunity.com/profiles/"+steamID+"/");
		client.chatMessage(steamID,/*,message+*/"\n\n[Mensaje automatico] :demoticon: Hola, De momento no me encuentro disponible :demoticon: \n\n");
        client.chatMessage(steamID,"Procura no hacer spam ya que podrias ser eliminado sin piedad por el bot ");
	}


});


client.on('friendRelationship', (steamID, relationship) => {
	if (relationship == 2) 
	{
		client.addFriend(steamID);
		client.chatMessage(steamID, "https://steamcommunity.com/profiles/"+steamID+"/ [Mensaje Automatico] Ahora mismo  ̷̷̢̧̢̧̐͂̾ͤͭ̐͂̾ͤͭƝ҉o҉i҉s҉e no se encuentra disponible, No escribas ->> !eliminar :demoticon:");
	}
});

the error arises when I try to convert "personas to an array"  --->  var persona = personas[steamID.getSteamID64()];

Posted (edited)
client.getPersonas([steamID], function(err,personas) {
            var persona = personas[steamID.getSteamID64()];
            var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]");
            console.log(name);
        }); 

this works, thanks

Edited by NoiseBaphomet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...