Skip to content

Instantly share code, notes, and snippets.

@Radvylf

Radvylf/ops.md Secret

Created May 26, 2022 23:18
Show Gist options
  • Save Radvylf/bba5d3273a80706eac78343a126bfeb0 to your computer and use it in GitHub Desktop.
Save Radvylf/bba5d3273a80706eac78343a126bfeb0 to your computer and use it in GitHub Desktop.

Transcript: Docs

Request format: HMAC(random + ops) + random + ops, hmac is SHA-512 (64 bytes), random is 8 bytes random data, ops is JSON array

Op format: All ops contain an op key, which is one of:

  • transcript: Read from a room's transcript
  • room: Add a room
  • drop_room: Remove a room
  • post: Add a message
  • modify: Edit a message
  • drop: Delete a message

Operations should be sent in batches, preferrably at least 24 at a time.

transcript

Single:

{
    "op": "transcript",
    "room": "AaBbCc-_",
    "id": 2
}

An id will fetch a single message, and return a response of:

{
    "post": (data)
}

Multiple:

{
    "op": "transcript",
    "room": "AaBbCc-_",
    "ids": [20, 86]
}

With ids, a range of messages are chosen (inclusive start, exclusive end). If no end is specified, all messages after a certain point are returned (most useful with negative numbers; [-17] gets the last 17 messages in a room, assuming sequential IDs). An empty array will return as much of the room's history as possible, ending with the last message. The maximum number of messages which can be requested at once is 1024. The result returned looks like this:

{
    "posts": [(data), (data), ...]
}

room

{
    "op": "room",
    "room": "NewRoom1"
}

Result:

{}

drop_room

{
    "op": "room",
    "room": "abcd----"
}

Result:

{
    "did_drop_room": true
}

This will be true if the room existed, and false if the room did not (and thus nothing happened).

post

{
    "op": "post",
    "room": "xyz-xyz-",
    "id": 11,
    "data": (data)
}

This will create a post. If a message with the chosen id already exists, it will be edited instead, and did_modify in the response will be true. The response looks like:

{
    "did_modify": false
}

modify

{
    "op": "modify",
    "room": "abc-dfg-",
    "id": -7,
    "data": (data)
}

This will edit a post. If a message with the chosen id doesn't exist, a new post will be made instead, and did_post in the response will be true. The response looks like:

{
    "did_post": false
}

drop

{
    "op": "modify",
    "room": "__frog__",
    "id": 0
}

This will delete a post. Result:

{
    "did_drop": true
}

This will be true if a message with the id existed, and false if one did not (and thus nothing happened).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment