Difference between revisions of "Bot Playground/Events/instant message"
From SmartBots Developers Docs
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:instant_message}} | {{DISPLAYTITLE:instant_message}} | ||
<onlyinclude>Fires when bot receives a message from another avatar or in-world object.</onlyinclude> | <onlyinclude>Fires when bot receives a message from another avatar or in-world object.</onlyinclude> | ||
+ | |||
+ | <syntaxhighlight lang="javascript"> | ||
+ | Bot.on("instant_message", function(event) { ... }); | ||
+ | </syntaxhighlight> | ||
{{API Event Table}} | {{API Event Table}} | ||
− | {{API Variable Group| | + | {{API Variable Group|''event'' object properties}} |
+ | {{API Variable|name}}The name of the event in this case instant_message | ||
+ | {{API Variable|speaker_type}}The sender of the message. Can be AVATAR or OBJECT | ||
+ | {{API Variable|speaker_name}}The name of the sender | ||
+ | {{API Variable|speaker_uuid}}The UUID of the sender | ||
{{API Variable|message}}The text of the message | {{API Variable|message}}The text of the message | ||
Line 12: | Line 20: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Bot.on("instant_message", function(event) { | Bot.on("instant_message", function(event) { | ||
− | + | console.log(event.speaker_name + " says: \n" + event.message); | |
}); | }); | ||
+ | |||
+ | console.log("Bot is listening, IM something"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | {{NavMenu}} |
Latest revision as of 12:30, 1 July 2016
Fires when bot receives a message from another avatar or in-world object.
Bot.on("instant_message", function(event) { ... });
Reference
This event comes with the following event object:
Variable | Required | Description | |
---|---|---|---|
event object properties: | |||
name | The name of the event in this case instant_message | ||
speaker_type | The sender of the message. Can be AVATAR or OBJECT | ||
speaker_name | The name of the sender | ||
speaker_uuid | The UUID of the sender | ||
message | The text of the message |
Example
Bot.on("instant_message", function(event) {
console.log(event.speaker_name + " says: \n" + event.message);
});
console.log("Bot is listening, IM something");