From 950971ef474384544e07a0d96dbc95a89a62dd54 Mon Sep 17 00:00:00 2001 From: hanemile Date: Fri, 10 Jul 2020 16:47:08 +0200 Subject: added some information regarding the functions to the README.md --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f66ecf --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# matrix + +This is a minimal implementation of the endpoints matrix provides for +communication inbetween the client and the server. + +## Functions + +The basic functions availible are described below. I'm pretty sure that I won't +update these farily often, so you're better of just using `go doc` for +searching through the functionnns. + +### Login + +``` +func Login(username, password, homeserver string) (Authinfo, error) +``` + +Used to get an authinfo struct containing information needed by other function +for functioning properly, such as the auth key needed to send messages. + +## Send + +``` +func Send(authinfo Authinfo, roomID string, message string) error +func SendImage(authinfo Authinfo, roomID string, image map[string]interface{}) error +``` + +Send and message or and image to a room you are in. +(Sending images is done by providing a map with information on the image: + +``` + image := map[string]interface{}{ + "msgtype": "m.image", + "url": mxc://matrix.emile.space/askhdlkajshdlkajhdslkjh, + "info": map[string]interface{}{ + "h": 1080, + "w": 1920, + "mimetype": "image/jpeg", + "size": 1337, + }, + "body": "some text associated with the image", +} +``` + +Most important: the url, that actually isn't a url but a mxc URI. To get one +upload your image using the upload function, you'll get that uri in the +response. + +## Sync + +``` +func Sync(authinfo Authinfo) (RespSync, error) +func SyncPartial(authinfo Authinfo, nextBatch string, eventsChannel chan PackagedEvent) (RespSync, error) +``` + +There are two syncs available: `Sync` and `syncPartial`. Sync is used to +syncronize the first time in order to get all events created. SyncPartial uses +a token returned by the Sync function to fetch all events created since that +token was given out (sort of a timestamp). + +This allows incremental fetches. + +## Upload + +``` +func Upload(authinfo Authinfo, filename string, file *bytes.Buffer) (UploadResponse, error) +``` + +The upload function uploads the given buffer to the homeserver that is provided +in the authinfo object. The response contains the mxc URI that can be used to +send the uploaded image to another participant. + -- cgit 1.4.1