aboutsummaryrefslogtreecommitdiff
path: root/appservice/matrix.go
diff options
context:
space:
mode:
Diffstat (limited to 'appservice/matrix.go')
-rw-r--r--appservice/matrix.go31
1 files changed, 28 insertions, 3 deletions
diff --git a/appservice/matrix.go b/appservice/matrix.go
index 96f643a..c85861d 100644
--- a/appservice/matrix.go
+++ b/appservice/matrix.go
@@ -135,6 +135,9 @@ func mxCreateRoom(name string, alias string, invite []string) (string, error) {
CreationContent: map[string]interface{} {
"m.federate": false,
},
+ PowerLevels: map[string]interface{} {
+ "invite": 100,
+ },
}
var rep CreateRoomResponse
err := mxPostApiCall("/_matrix/client/r0/createRoom", &rq, &rep)
@@ -144,6 +147,28 @@ func mxCreateRoom(name string, alias string, invite []string) (string, error) {
return rep.RoomId, nil
}
+func mxCreateDirectRoomAs(name string, invite []string, as_user string) (string, error) {
+ rq := CreateRoomNoAliasRequest{
+ Preset: "private_chat",
+ Name: name,
+ Topic: "",
+ Invite: invite,
+ CreationContent: map[string]interface{} {
+ "m.federate": false,
+ },
+ PowerLevels: map[string]interface{} {
+ "invite": 100,
+ },
+ IsDirect: true,
+ }
+ var rep CreateRoomResponse
+ err := mxPostApiCall("/_matrix/client/r0/createRoom?user_id=" + url.QueryEscape(as_user), &rq, &rep)
+ if err != nil {
+ return "", err
+ }
+ return rep.RoomId, nil
+}
+
func mxRoomInvite(room string, user string) error {
rq := RoomInviteRequest{
UserId: user,
@@ -177,10 +202,10 @@ func mxRoomLeaveAs(room string, user string) error {
return err
}
-func mxSendMessageAs(room string, body string, user string) error {
+func mxSendMessageAs(room string, typ string, body string, user string) error {
txn_id := time.Now().UnixNano()
- rq := RoomSendRequest{
- MsgType: "m.text",
+ rq := RoomSendMessageRequest{
+ MsgType: typ,
Body: body,
}
var rep RoomSendResponse