Difference between revisions of "Bot Playground/Events/script dialog"
From SmartBots Developers Docs
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:script_dialog}} | {{DISPLAYTITLE:script_dialog}} | ||
− | <onlyinclude>Fires when bot receives a scripted dialog</onlyinclude> | + | <onlyinclude>Fires when bot receives a scripted dialog with a menu buttons</onlyinclude> |
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Bot.on("script_dialog", function(event) { ... }); | Bot.on("script_dialog", function(event) { ... }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | Use [[Bot Playground/Commands/replyDialog|replyDialog]] to "click" a required menu button. | ||
{{API Event Table}} | {{API Event Table}} | ||
{{API Variable Group|''event'' object properties}} | {{API Variable Group|''event'' object properties}} | ||
{{API Variable|name}}The name of the event in this case script_dialog | {{API Variable|name}}The name of the event in this case script_dialog | ||
− | {{API Variable|buttons}} The selection options (buttons) | + | {{API Variable|buttons|Array}} The selection options (buttons) as array |
− | {{API Variable|channel}} The channel on which the dialog listen to. | + | {{API Variable|channel|integer}} The channel on which the dialog listen to. |
{{API Variable|owner_name}} The owner name from object that sent the dialog. | {{API Variable|owner_name}} The owner name from object that sent the dialog. | ||
{{API Variable|text}} The text in the dialog window | {{API Variable|text}} The text in the dialog window | ||
Line 22: | Line 24: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Bot.on("script_dialog", function(event) { | Bot.on("script_dialog", function(event) { | ||
− | + | console.log("Got a dialog:\n" + | |
+ | event.text + "\n\n" + | ||
+ | "channel: " + event.channel + "\n" + | ||
+ | "buttons:\n" + event.buttons.join("\n")); | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{NavMenu}} | {{NavMenu}} |
Latest revision as of 12:06, 17 June 2019
Fires when bot receives a scripted dialog with a menu buttons
Bot.on("script_dialog", function(event) { ... });
Use replyDialog to "click" a required menu button.
Reference
This event comes with the following event object:
Variable | Required | Description | |
---|---|---|---|
event object properties: | |||
name | The name of the event in this case script_dialog | ||
buttons | Array | The selection options (buttons) as array | |
channel | integer | The channel on which the dialog listen to. | |
owner_name | The owner name from object that sent the dialog. | ||
text | The text in the dialog window | ||
object_uuid | The UUID of the object that sent the dialog. | ||
object_name | The name of the object that sent the dialog. |
Example
Bot.on("script_dialog", function(event) {
console.log("Got a dialog:\n" +
event.text + "\n\n" +
"channel: " + event.channel + "\n" +
"buttons:\n" + event.buttons.join("\n"));
});