queue.sizeReturns the number of user messages.
Signature: queue.size() int
Arguments: No arguments.
Return value: An integer — the number of user messages for the entire duration of the dialogue.
Example of use:
$messageCount = queue.size() // $messageCount contains the number of user messages for the entire duration of the dialogue
queue.lastReturns the last user message or nil if the message queue is empty.
Signature: queue.last() ?UserMessage
Arguments: No arguments.
Return value: UserMessage object or nil.
Example of use:
$lastMessage = queue.last() // $lastMessage contains the last user message at the moment
queue.firstReturns the first user message or nil if the message queue is empty.
Signature: queue.first() ?UserMessage
Arguments: No arguments.
Return value: UserMessage object or nil.
Example of use:
$firstMessage = queue.first() // $firstMessage contains the first user message in the entire dialogue
queue.nthReturns a user message by its ordinal number, starting from 1.
Signature: queue.nth(index int) ?UserMessage
Arguments: index — the ordinal number of the user message.
Return value: A UserMessage object or nil.
Usage examples:
$message = queue.nth(1) // $message contains the first user message
$message = queue.nth(5) // $message contains the fifth user message
queue.lastNthReturns a user message by its ordinal number, counting from the end of the queue. The last message corresponds to ordinal number 1.
Signature: queue.lastNth(index int) ?UserMessage
Arguments: index — the ordinal number of the user message, counting from the end of the queue.
Return value: UserMessage object or nil.
Usage examples:
$message = queue.lastNth(1) // $message contains the last user message
$message = queue.lastNth(5) // $message contains the fifth user message from the end of the queue