From 6c242710d7b1e4ba7c7d9b76437529d1d00c7c67 Mon Sep 17 00:00:00 2001 From: hanemile Date: Fri, 10 Jul 2020 16:37:52 +0200 Subject: the functions handling almost everything I need --- join.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 join.go (limited to 'join.go') diff --git a/join.go b/join.go new file mode 100644 index 0000000..bc274c0 --- /dev/null +++ b/join.go @@ -0,0 +1,32 @@ +package matrix + +import ( + "fmt" + + "gopkg.in/h2non/gentleman.v2" + "gopkg.in/h2non/gentleman.v2/plugins/query" +) + +func join(authinfo Authinfo, roomIdentifier string) error { + cli := gentleman.New() + cli.URL(authinfo.HomeServer) + + req := cli.Request() + req.Path(fmt.Sprintf("/_matrix/client/r0/rooms/%s/join", roomIdentifier)) + req.Method("POST") + + req.Use(query.Set("access_token", authinfo.AccessToken)) + + res, err := req.Send() + if err != nil { + fmt.Println("ERR1") + return err + } + if !res.Ok { + fmt.Println("ERR2") + fmt.Println(res) + return err + } + + return nil +} -- cgit 1.4.1