Jump to content
McKay Development

Recommended Posts

Posted

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.

Posted

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.

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...