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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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.
|