Don't parse room ID
This commit is contained in:
parent
248db71c76
commit
1e6b599649
@ -35,7 +35,7 @@ type MatrixContainer interface {
|
|||||||
SendMessage(roomID, msgtype, message string) (string, error)
|
SendMessage(roomID, msgtype, message string) (string, error)
|
||||||
SendMarkdownMessage(roomID, msgtype, message string) (string, error)
|
SendMarkdownMessage(roomID, msgtype, message string) (string, error)
|
||||||
SendTyping(roomID string, typing bool)
|
SendTyping(roomID string, typing bool)
|
||||||
JoinRoom(roomID string) (*rooms.Room, error)
|
JoinRoom(roomID, server string) (*rooms.Room, error)
|
||||||
LeaveRoom(roomID string) error
|
LeaveRoom(roomID string) error
|
||||||
|
|
||||||
GetHistory(roomID, prevBatch string, limit int) ([]gomatrix.Event, string, error)
|
GetHistory(roomID, prevBatch string, limit int) ([]gomatrix.Event, string, error)
|
||||||
|
@ -438,16 +438,11 @@ func (c *Container) SendTyping(roomID string, typing bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JoinRoom makes the current user try to join the given room.
|
// JoinRoom makes the current user try to join the given room.
|
||||||
func (c *Container) JoinRoom(roomID string) (*rooms.Room, error) {
|
func (c *Container) JoinRoom(roomID, server string) (*rooms.Room, error) {
|
||||||
if len(roomID) == 0 {
|
if len(roomID) == 0 {
|
||||||
return nil, fmt.Errorf("invalid room ID")
|
return nil, fmt.Errorf("invalid room ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
server := ""
|
|
||||||
if roomID[0] == '!' {
|
|
||||||
server = roomID[strings.Index(roomID, ":")+1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := c.client.JoinRoom(roomID, server, nil)
|
resp, err := c.client.JoinRoom(roomID, server, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -164,7 +164,12 @@ func (view *MainView) HandleCommand(roomView *RoomView, command string, args []s
|
|||||||
roomView.AddServiceMessage("Usage: /join <room>")
|
roomView.AddServiceMessage("Usage: /join <room>")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
room, err := view.matrix.JoinRoom(args[0])
|
identifer := args[0]
|
||||||
|
server := ""
|
||||||
|
if len(args) > 1 {
|
||||||
|
server = args[1]
|
||||||
|
}
|
||||||
|
room, err := view.matrix.JoinRoom(identifer, server)
|
||||||
debug.Print("Join room error:", err)
|
debug.Print("Join room error:", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
view.AddRoom(room)
|
view.AddRoom(room)
|
||||||
|
Loading…
Reference in New Issue
Block a user