Jump to content


Photo
Question

How can I get data from the user?

node.js node-steam-user

Best Answer SunriseM , 30 April 2017 - 10:29 PM

You can use "split" to convert the string to array and get the part you want. Example:

client.on('friendOrChatMessage', (senderID, message) => {
   //Example Message: /bet 45
   var arrmsg = message.split(" ") //arrmsg = ["/bet","45"]
   var userNumber = arrmsg[1]
   if (message.indexOf("/bet") == 0){
      client.chatMessage(senderID, 'Your bet is: ' + userNumber);
   }
});

You will have to add other things like be sure that input has /bet [number],  verify the number can be used, etc

Go to the full post


  • Please log in to reply
1 reply to this topic

#1 Lobadzip

Lobadzip

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 30 April 2017 - 09:56 AM

Hi guys! At the moment I'm working on a chat-bot Steam, the essence of which will be giving out things for winning in the game, and all this will happen right in the bot, but I ran into the problem that I can not get data from the user:

  client.on('friendOrChatMessage', (senderID, message) => {

if (message.indexOf("/bet %user number%") == 0){
			client.chatMessage(senderID, 'Your bet is: ' + %user number%);
		}
});

where %user number% is the number that the user enters, but I do not know how it can be implemented :C

 

Is it even possible to do this and how? Please help me!



#2 SunriseM

SunriseM

    Advanced Member

  • Member
  • PipPipPip
  • 46 posts
  • LocationVenezuela

Posted 30 April 2017 - 10:29 PM   Best Answer

You can use "split" to convert the string to array and get the part you want. Example:

client.on('friendOrChatMessage', (senderID, message) => {
   //Example Message: /bet 45
   var arrmsg = message.split(" ") //arrmsg = ["/bet","45"]
   var userNumber = arrmsg[1]
   if (message.indexOf("/bet") == 0){
      client.chatMessage(senderID, 'Your bet is: ' + userNumber);
   }
});

You will have to add other things like be sure that input has /bet [number],  verify the number can be used, etc


  • Lobadzip likes this





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