Browse Source

added some information regarding the functions to the README.md

master
emile 2 years ago
parent
commit
950971ef47
Signed by: emile
GPG Key ID: 4D8DD313A751DED7
  1. 72
      README.md

72
README.md

@ -0,0 +1,72 @@ @@ -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.
Loading…
Cancel
Save