botserver/docs/src/chapter-05/keyword-wait.md
Rodrigo Rodriguez (Pragmatismo) e5ac6b7051 docs: expand session management and add authentication section
Enhanced Chapter 1 documentation with detailed session architecture, storage layers, and API endpoints. Added new Part XI on authentication and security to SUMMARY.md, introducing chapters on user and bot authentication, password security, and API endpoints. Improves clarity and coverage of system interaction and security concepts.
2025-11-03 20:42:38 -03:00

1.8 KiB

WAIT Keyword

The WAIT keyword pauses script execution for a specified duration.
It is used to introduce delays between actions, synchronize processes, or control timing in automation flows.


Syntax

WAIT seconds

Parameters

  • seconds — The number of seconds to pause execution.
    Can be an integer or floating-point value.
    The maximum allowed duration is 300 seconds (5 minutes).

Description

WAIT suspends the script for the specified duration.
During this time, the bot does not process other commands or messages.
This keyword is useful for pacing interactions, waiting for external events, or throttling API calls.

If the provided value is invalid (negative or non-numeric), the command raises a runtime error.
The system automatically caps the wait time to prevent excessively long pauses.


Example

' Wait for 2 seconds before continuing
TALK "Processing your request..."
WAIT 2
TALK "Done!"

Implementation Notes

  • Implemented in Rust under src/basic/mod.rs and src/shared/utils.rs.
  • Uses std::thread::sleep with a Duration derived from the provided seconds.
  • The engine ensures that the wait does not exceed the configured timeout limit.
  • During the wait, no other BASIC commands are executed.

  • SET_SCHEDULE — Defines scheduled tasks for automation.
  • PRINT — Outputs messages or debugging information.
  • TALK — Sends messages to the user.
  • HEAR — Receives user input after a delay.

Summary

WAIT is a simple but essential keyword for controlling timing in BASIC scripts.
It allows developers to create natural pauses, synchronize workflows, and manage execution pacing effectively.