Add pm command
This commit is contained in:
parent
7c39729ada
commit
ae3bb9c7a3
@ -82,6 +82,9 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
|||||||
"state": {"setstate"},
|
"state": {"setstate"},
|
||||||
"mstate": {"msetstate"},
|
"mstate": {"msetstate"},
|
||||||
"rb": {"rainbow"},
|
"rb": {"rainbow"},
|
||||||
|
"createroom": {"create"},
|
||||||
|
"dm": {"pm"},
|
||||||
|
"query": {"pm"},
|
||||||
},
|
},
|
||||||
commands: map[string]CommandHandler{
|
commands: map[string]CommandHandler{
|
||||||
"unknown-command": cmdUnknownCommand,
|
"unknown-command": cmdUnknownCommand,
|
||||||
@ -91,6 +94,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
|||||||
"clearcache": cmdClearCache,
|
"clearcache": cmdClearCache,
|
||||||
"leave": cmdLeave,
|
"leave": cmdLeave,
|
||||||
"create": cmdCreateRoom,
|
"create": cmdCreateRoom,
|
||||||
|
"pm": cmdPrivateMessage,
|
||||||
"join": cmdJoin,
|
"join": cmdJoin,
|
||||||
"kick": cmdKick,
|
"kick": cmdKick,
|
||||||
"ban": cmdBan,
|
"ban": cmdBan,
|
||||||
|
@ -27,8 +27,9 @@ import (
|
|||||||
|
|
||||||
"github.com/lucasb-eyer/go-colorful"
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
|
|
||||||
"maunium.net/go/gomuks/debug"
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
|
|
||||||
|
"maunium.net/go/gomuks/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cmdMe(cmd *Command) {
|
func cmdMe(cmd *Command) {
|
||||||
@ -122,6 +123,7 @@ func cmdHelp(cmd *Command) {
|
|||||||
/rainbow <message> - Send a rainbow message (markdown not supported).
|
/rainbow <message> - Send a rainbow message (markdown not supported).
|
||||||
|
|
||||||
/create [room name] - Create a room.
|
/create [room name] - Create a room.
|
||||||
|
/pm <user id> <...> - Create a private chat with the given user(s).
|
||||||
/join <room address> - Join a room.
|
/join <room address> - Join a room.
|
||||||
/leave - Leave the current room.
|
/leave - Leave the current room.
|
||||||
|
|
||||||
@ -201,7 +203,6 @@ func cmdKick(cmd *Command) {
|
|||||||
debug.Print("Error in kick call:", err)
|
debug.Print("Error in kick call:", err)
|
||||||
debug.Print("Failed to kick user:", err)
|
debug.Print("Failed to kick user:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdCreateRoom(cmd *Command) {
|
func cmdCreateRoom(cmd *Command) {
|
||||||
@ -217,6 +218,22 @@ func cmdCreateRoom(cmd *Command) {
|
|||||||
cmd.MainView.SwitchRoom("", room)
|
cmd.MainView.SwitchRoom("", room)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cmdPrivateMessage(cmd *Command) {
|
||||||
|
if len(cmd.Args) == 0 {
|
||||||
|
cmd.Reply("Usage: /pm <user id> [more user ids...]")
|
||||||
|
}
|
||||||
|
req := &mautrix.ReqCreateRoom{
|
||||||
|
Preset: "trusted_private_chat",
|
||||||
|
Invite: cmd.Args,
|
||||||
|
}
|
||||||
|
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) {
|
func cmdJoin(cmd *Command) {
|
||||||
if len(cmd.Args) == 0 {
|
if len(cmd.Args) == 0 {
|
||||||
cmd.Reply("Usage: /join <room>")
|
cmd.Reply("Usage: /join <room>")
|
||||||
|
Loading…
Reference in New Issue
Block a user