TextDynasty Posted November 8, 2016 Report Share Posted November 8, 2016 Is there any way to identify chat message? Like if people say hi to you and you will say hi or hello? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted November 8, 2016 Report Share Posted November 8, 2016 https://github.com/DoctorMcKay/node-steam-user#friendorchatmessage Quote Link to comment Share on other sites More sharing options...
Frost Byte Posted November 8, 2016 Report Share Posted November 8, 2016 Like Dr. McKay said, you can use the event friendOrChatMessage to find out if someone send you a message, so you can respond to them. I have the other method friendMessage, which will only send something back when you get a message from a friend. // When we get a message, send back a response and log to console client.on("friendMessage", function(steamID, message) { console.log("Friend message from " + steamID+ ": " + message); if (message == "Ping") { client.chatMessage(steamID, "Pong"); console.log("Send back: Pong"); } else { client.chatMessage(steamID, config.greetMsg); console.log("Send back the standard reply"); } }); }); When your bot gets the message 'Ping' it will send back 'Pong'.If your bot gets a different message, it will respond with a standard reply which you should create in your config.json file. If you want more reply options, I'd suggest creating a switch statement with several cases. Quote Link to comment Share on other sites More sharing options...
TextDynasty Posted November 8, 2016 Author Report Share Posted November 8, 2016 Like Dr. McKay said, you can use the event friendOrChatMessage to find out if someone send you a message, so you can respond to them. I have the other method friendMessage, which will only send something back when you get a message from a friend. // When we get a message, send back a response and log to console client.on("friendMessage", function(steamID, message) { console.log("Friend message from " + steamID+ ": " + message); if (message == "Ping") { client.chatMessage(steamID, "Pong"); console.log("Send back: Pong"); } else { client.chatMessage(steamID, config.greetMsg); console.log("Send back the standard reply"); } }); }); When your bot gets the message 'Ping' it will send back 'Pong'.If your bot gets a different message, it will respond with a standard reply which you should create in your config.json file. If you want more reply options, I'd suggest creating a switch statement with several cases. Thanks for the explanation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.