rMail
Overview
The rMail system provides a simple but powerful messaging framework for users within the roturTW environment. This documentation outlines how to interact with the rMail API, covering request formats, available commands, response structures, and usage examples.
Core Concepts
rMail operates on a packet-based communication system where clients send command packets and receive formatted responses. All interactions are JSON-based and follow consistent formatting patterns.
Packet Format
Request Packet Structure
All requests to the rMail system use the following packet format:
Key components:
cmd
: Always set to "pmsg" for rMail operationsval
: Contains the command detailssource
: Identifier of the requesting clientcommand
: The specific rMail operation to performpayload
: Data relevant to the command (varies by command type)origin
: Contains authentication informationrotur
: Username of the sender (will be converted to lowercase)
Available Commands
1. Get Mail Information (omail_getinfo
)
omail_getinfo
)Retrieves summary information about all rMails for the authenticated user.
Request:
Response:
2. Send Mail (omail_send
)
omail_send
)Sends a new rMail to another user.
Request:
Response (Success):
Response (Rate Limited):
3. Delete Mail (omail_delete
)
omail_delete
)Deletes a specific rMail or all rMails for the authenticated user.
Request (Delete Specific rMail):
Request (Delete All rMails):
Response:
4. Get rMail Count (omail_total
)
omail_total
)Retrieves the total number of rMails for the authenticated user.
Request:
Response:
5. Get rMail by ID (omail_getid
)
omail_getid
)Retrieves the full content of a specific rMail by its index.
Request:
Response:
Limitations and Constraints
The rMail system has several built-in limitations:
Rate Limiting: Users can only send one rMail every 60 seconds.
Size Limits:
rMail payloads cannot exceed 50KB in size
rMail titles cannot exceed 100 characters
Storage: rMails are stored in a JSON file (
rmails.json
) on the server
Data Structure
rMails are stored in the following structure:
Implementation Details
Storage Files
The rMail system uses two main storage files:
rmails.json: Stores all rMail data, organized by username
rmail_ratelimits.json: Tracks the last time each user sent a rMail for rate limiting
rMail Indexing
New rMails are inserted at the beginning of a user's rMail list (index 0)
Both sender and recipient receive a copy of each rMail
rMail IDs used in client interfaces are 1-based, but internally they're 0-based
Example Usage Scenarios
Checking for New rMails
Sending a rMail
Reading a Specific rMail
Error Handling
The rMail system provides minimal error handling:
If a requested rMail doesn't exist, an empty object is returned
If a command is unrecognized, no response is sent
Invalid deletion indices are silently ignored
Best Practices
Always handle rate limiting gracefully by informing users when they need to wait
Cache rMail information when possible to reduce server load
Implement appropriate error handling for cases where rMails might not exist
Keep rMail content reasonably sized to avoid hitting the 50KB limit
Last updated