aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: c540718894c380ec3de05a26e6d26f0ca0eaf2a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# N Core - the backend of N  
## N protocol  
### request  
Each message sent to the N core server must be valid JSON and have a `command` field. It contains the command for N to handle, sanitizied (i.e. no leading '/' or trailing username etc).  
The arguments field contains the remaining text just as was send to the bridge.  
All messages may optionally include an `session` field. When you authorize against N core or switch to a menu, you will be returned (see next section) a session id which you can then send with this field to follow up on the inital command.  
  
| Field | Type | Required? | Description |  
|-------|------|-----------|-------------|  
| `command` | string | yes | The command N core should handle |  
| `arguments` | string | no | The arguments to the command (i.e. all remaining text in the message |  
| `session` | string | no | The session id, defaults to `null` |  
  
### answer  
The answer consists of an array of `reply` objects, an `success`-flag and a `session`-id provided by N core.  
The reply objects enable N core to request certain formatting from the bridges, which they should try to implement as close as the underlying platform supports it. In any case, the plain text stringed together from all replies `text` field should be enough to get the message to the user, annotations should be fully optional.  
The session id can be ignored by bridges, but this will opt the bridge out of more complex (context specific) commands.  
JSON object overview:  
  
| Field | Type | Required? | Description |  
|-------|------|-----------|-------------|  
| `reply` | array of `reply`-objects | yes | The reply from N core |  
| `success` | bool | yes | Whether the command was successful |  
| `session` | string | yes | A session id, defaults to `null` |  
  
#### `reply`  
The `reply` object:  
  
| Field | Type | Required? | Description |  
|-------|------|-----------|-------------|  
| `text` | string | yes | A part of the answer |  
| `annotations` | yes | array of `annotation`-objects | The annotations to this answer part |  
  
#### `annotation`  
The `annotation` object:  
  
| Field | Type | Required? | Description |  
|-------|------|-----------|-------------|  
| `type` | string | yes | A part of the answer |  
| `extra` | string | no | Extra content specific to the annotation type |  
  
The currently specified annotation types are enumerated below:  
  
##### `bold`
The text should be printed as bold. No extra content.  
  
##### `italic`
The text should be printed as italic. No extra content.  
  
##### `strikethrough`
The text should be printed as strikethrough. No extra content.  
  
##### `underline`
The text should be printed as underline. No extra content.  
  
##### `link`
The text should be formatted as a link. Extra content: the uri to link.