aboutsummaryrefslogtreecommitdiffstats

N Core - the backend of N

Build upon crow forked to fix a deprecation in boost 1.7+

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, sanitized (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 initial 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 array of reply-objects no Extra content specific to the annotation type

The currently specified annotation types are enumerated below:

none

The text should be printed as plain text. No extra content.

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.

command

The text should be printed as a command how did bridge will recognize it (e.g. prefix with '/').
Extra content: the description of the command.

The text should be formatted as a link. Extra content: the alt text for the uri - the uri should be the text itself, so that clients ignoring this annotation still show the real uri.