Difference between revisions of "AdminBot for LSL/Events"

From SmartBots Developers Docs
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
== Parsing Events ==
 
== Parsing Events ==
 +
 
LSL link_message event has the following syntax:
 
LSL link_message event has the following syntax:
  
 
<syntaxhighlight lang="lsl">
 
<syntaxhighlight lang="lsl">
link_message( integer sender_num, integer num, string str, key id )
+
link_message(integer sender_num, integer num, string str, key id) {
 +
  if(num == SB_SETUP_SUCCESS) {
 +
    ...
 +
  }
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
For AdminBot, '''num''' will contain the event code (see below). '''str''' and '''id''' value depend on the event.
+
For AdminBot event, '''num''' contains the event code (see below). '''str''' and '''id''' value depend on the event. Refer to the table below for more info.
  
 
== Events List ==
 
== Events List ==
  
The following events can be raised by AdminBot gateway:
+
The following events can be raised by AdminBot:
  
{| width=100%
+
{{API Table start|Command|Description}}
! Event / Description
+
! width=200 | str
+
! width=150 | id
+
|-
+
| colspan="3" |
+
=== Status events ===
+
|- class="row-b"
+
| colspan="3" | SB_COMMAND_FAILED
+
|-
+
| Raised when command error occurs.
+
| class="row-a" | first line - [[AdminBot_for_Groups/Documentation/Status_Codes|command status code]]<br>second line - text explaination
+
| class="row-a" | ---
+
|- class="row-b"
+
| colspan="3" | SB_SETUP_SUCCESS
+
|-
+
| Raised when group has been set '''successfully''' (group exists and not expired)
+
| class="row-a" | group name
+
| class="row-a" | group UUID
+
|- class="row-b"
+
| colspan="3" | SB_SETUP_FAILED
+
|-
+
| Raised when there was an error setting the group (group does not exist, expired etc)
+
| class="row-a" | first line - [[AdminBot_for_Groups/Documentation/Status_Codes|group status code]]<br>second life - group expiration date
+
| class="row-a" | ---
+
|- class="row-b"
+
| colspan="3" | SB_SETUP_BOTNAME
+
|-
+
| Raised after successful AdminBot initialization. Delivers the bot name and UUID serving the choosen group.
+
| class="row-a" | SL bot name
+
| class="row-a" | SL bot UUID
+
  
|-
+
{{API Group|Command execution status}}
| colspan="3" |
+
{{API Entry|AdminBot|SB_COMMAND_FAILED}}
 +
{{API Entry|AdminBot|SB_COMMAND_COMPLETED}}
  
=== Group status request events ===
+
{{API Group|Setup status}}
|- class="row-b"
+
{{API Entry|AdminBot|SB_SETUP_SUCCESS}}
| colspan="3" | SB_STATUS_REPLY
+
{{API Entry|AdminBot|SB_SETUP_FAILED}}
|-
+
{{API Entry|AdminBot|SB_SETUP_BOTNAME}}
| Reply when you request the group status using [[AdminBot_for_Groups/Commands|SB_STATUS_QUERY]]
+
| class="row-a" | first line - [[AdminBot_for_Groups/Documentation/Status_Codes|group status code]]<br>second line - group expiration date
+
| class="row-a" | group UUID
+
  
|-
+
{{API Group|Group status request events}}
| colspan="3" |
+
{{API Entry|AdminBot|SB_STATUS_REPLY}}
  
=== Avatar status request events ===
+
{{API Group|Avatar status request events}}
|- class="row-b"
+
{{API Entry|AdminBot|SB_GROUP_CHECKED}}
| colspan="3" | SB_GROUP_CHECKED
+
|-
+
| The reply to a [[AdminBot_for_Groups/Commands/SB_AVATAR_GROUP|SB_AVATAR_GROUP]] command.
+
| class="row-a" | 0 - avatar is not in the group
+
1 - avatar is in the group
+
| class="row-a" | avatar UUID
+
  
|-
+
{{API Group|Group chat events}}
| colspan="3" |
+
{{API Entry|AdminBot|SB_CHAT_SUCCESS}}
 +
{{API Entry|AdminBot|SB_CHAT_MESSAGE}}
  
=== Group chat events ===
+
{{API Table end}}
|- class="row-b"
+
| colspan="3" | SB_CHAT_SUCCESS
+
|-
+
| Raised when bot successfully connects to the group chat (see [[AdminBot_for_Groups/Commands/SB CHAT LISTEN|SB_CHAT_LISTEN]])
+
| class="row-a" | ---
+
| class="row-a" | Group UUID
+
|- class="row-b"
+
| colspan="3" | SB_CHAT_MESSAGE
+
|-
+
| Raised when bot receives the group chat message.
+
'''*Group chat saving must be enabled.'''
+
| class="row-a" | Resident name: Message
+
| class="row-a" | Resident UUID
+
|}
+
  
The numeric values are available here: [[AdminBot Examples: Header variables|Commands and events values]].
+
The numeric values are available here: [[AdminBot_for_LSL/Examples/Headers|Commands and events IDs]].
  
 
{{NavMenu}}
 
{{NavMenu}}
  
 
__NOTOC__
 
__NOTOC__

Latest revision as of 11:48, 3 November 2017

AdminBot raises events to inform your script about errors, chat IMs and other things happened. To catch it, use the LSL link_message event (see AdminBot Examples for usage patterns).

Parsing Events

LSL link_message event has the following syntax:

link_message(integer sender_num, integer num, string str, key id) {
  if(num == SB_SETUP_SUCCESS) {
    ...
  }
}

For AdminBot event, num contains the event code (see below). str and id value depend on the event. Refer to the table below for more info.

Events List

The following events can be raised by AdminBot:

Command Description

Command execution status

SB_COMMAND_FAILED Raised when command execution error occurs.
SB_COMMAND_COMPLETED Raised when command execution completes without errors.

Setup status

SB_SETUP_SUCCESS Raised when group has been set successfully (group exists and not expired)
SB_SETUP_FAILED Raised when there was an error setting the group (group does not exist, expired etc)
SB_SETUP_BOTNAME Raised after successful AdminBot initialization. Delivers the bot name and UUID serving the choosen group.

Group status request events

SB_STATUS_REPLY Replies when you request the group status using SB_STATUS_QUERY

Avatar status request events

SB_GROUP_CHECKED The reply of the SB_AVATAR_GROUP command.

Group chat events

SB_CHAT_SUCCESS Raised when bot successfully connects to the group chat (see SB_CHAT_LISTEN)
SB_CHAT_MESSAGE Raised when bot receives the group chat message.

The numeric values are available here: Commands and events IDs.