mirror of
https://github.com/mt-mods/mail.git
synced 2025-07-20 13:14:52 -04:00
separated from webmail mod
This commit is contained in:
commit
ca88374fbd
19 changed files with 941 additions and 0 deletions
60
api.md
Normal file
60
api.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
# Mail format
|
||||
The mail format in the api hooks
|
||||
|
||||
```lua
|
||||
mail = {
|
||||
sender = "source name",
|
||||
receiver = "destination name",
|
||||
subject = "subject line",
|
||||
body = "mail body",
|
||||
-- 8 attachments max
|
||||
attachments = {"default:stone 99", "default:gold_ingot 99"}
|
||||
}
|
||||
```
|
||||
|
||||
## Sending mail
|
||||
Old variant (pre-1.1)
|
||||
```lua
|
||||
mail.send("source name", "destination name", "subject line", "mail body")
|
||||
```
|
||||
|
||||
New variant (1.1+)
|
||||
```lua
|
||||
mail.send({
|
||||
sender = "source name",
|
||||
receiver = "destination name",
|
||||
subject = "subject line",
|
||||
body = "mail body"
|
||||
})
|
||||
```
|
||||
|
||||
# Hooks
|
||||
On-receive mail hook:
|
||||
|
||||
```lua
|
||||
mail.register_on_receive(function(m)
|
||||
-- "m" is an object in the form: "Mail format"
|
||||
end)
|
||||
```
|
||||
|
||||
# internal mail format (on-disk)
|
||||
The mail format on-disk
|
||||
|
||||
> (worldfolder)/mails/(playername).json
|
||||
|
||||
```json
|
||||
[{
|
||||
"unread": true,
|
||||
"sender": "sender name",
|
||||
"receiver": "receiver name",
|
||||
"subject": "subject name",
|
||||
"body": "main\nmultiline\nbody",
|
||||
"time": 1551258349,
|
||||
"attachments": [
|
||||
"default:stone 99",
|
||||
"default:gold_ingot 99"
|
||||
]
|
||||
}]
|
||||
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue