aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-06-14 20:56:41 +0300
committerTulir Asokan <tulir@maunium.net>2019-06-14 20:56:41 +0300
commit7c39729ada794aa2bfe91028ae3f3cfd3020de6f (patch)
treee0849f82637631baa5b800b32e5534fc2884329b /ui
parentfcd44fe63fe0cedc038db92ae39507237cc5589a (diff)
Remove room alias argument and switch to room after creating
Diffstat (limited to 'ui')
-rw-r--r--ui/commands.go32
1 files changed, 9 insertions, 23 deletions
diff --git a/ui/commands.go b/ui/commands.go
index c2102fd..b418e84 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -121,7 +121,7 @@ func cmdHelp(cmd *Command) {
/me <message> - Send an emote message.
/rainbow <message> - Send a rainbow message (markdown not supported).
-/create <Room Name> <RoomAlias> - Create a room with associated alias. (Alias must not contain spaces.)
+/create [room name] - Create a room.
/join <room address> - Join a room.
/leave - Leave the current room.
@@ -205,30 +205,16 @@ func cmdKick(cmd *Command) {
}
func cmdCreateRoom(cmd *Command) {
- if len(cmd.Args) < 2 {
- cmd.Reply("Usage: /create <Room Name> <RoomAlias> (Alias must not contain spaces.)")
- return
- }
- // Get room name as one string from cmd.Args
- roomName := ""
- for i, v := range cmd.Args {
- if i == len(cmd.Args)-1 {
- break
- }
- roomName += fmt.Sprintf("%s ", v)
+ req := &mautrix.ReqCreateRoom{}
+ if len(cmd.Args) > 0 {
+ req.Name = strings.Join(cmd.Args, " ")
}
- last := len(cmd.Args) - 1 // last arg for room alias
- // Build the ReqCreateRoom Struct
- // https://godoc.org/maunium.net/go/mautrix#ReqCreateRoom
- req := &mautrix.ReqCreateRoom{
- Name: strings.TrimSpace(roomName),
- RoomAliasName: cmd.Args[last],
- }
- _, err := cmd.Matrix.Client().CreateRoom(req)
- debug.Print("Create room error:", err)
- if err == nil {
- cmd.Reply("The room has been created.")
+ room, err := cmd.Matrix.CreateRoom(req)
+ if err != nil {
+ cmd.Reply("Failed to create room:", err)
+ return
}
+ cmd.MainView.SwitchRoom("", room)
}
func cmdJoin(cmd *Command) {