aboutsummaryrefslogtreecommitdiff
path: root/ui/commands.go
diff options
context:
space:
mode:
authorPascal Abresch <neplevitan@packageloss.eu>2019-03-19 16:06:40 +0100
committerPascal Abresch <neplevitan@packageloss.eu>2019-03-19 16:06:40 +0100
commitcefa840c28067e33bf67dd65aa267779cdeae34e (patch)
treec3c371a4033a85faaed0524c779aef66f60784bf /ui/commands.go
parentc5bf3f894c4efad71757f0d64ec128c01cdc5805 (diff)
adds kick, ban, unban and invite command
Diffstat (limited to 'ui/commands.go')
-rw-r--r--ui/commands.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/ui/commands.go b/ui/commands.go
index eb2a442..bba1644 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -112,6 +112,64 @@ func cmdLeave(cmd *Command) {
}
}
+func cmdInvite(cmd *Command) {
+ if len(cmd.Args) != 1 {
+ cmd.Reply("Usage: /invite <user id>")
+ return
+ }
+ _, err := cmd.Matrix.Client().InviteUser(cmd.Room.MxRoom().ID, &mautrix.ReqInviteUser{cmd.Args[0]})
+ if err != nil {
+ debug.Print("Error in invite call:", err)
+ cmd.Reply("Failed to invite user:", err)
+ }
+}
+
+func cmdBan(cmd *Command) {
+ if len(cmd.Args) < 1 {
+ cmd.Reply("Usage: /ban <user> <optional:reason>")
+ return
+ }
+ reason := "you are the weakest link, goodbye!"
+ if len(cmd.Args) >= 2 {
+ reason = strings.Join(cmd.Args[1:]," ")
+ }
+ _, err := cmd.Matrix.Client().BanUser(cmd.Room.MxRoom().ID, &mautrix.ReqBanUser{reason,cmd.Args[0]})
+ if err != nil {
+ debug.Print("Error in ban call:", err)
+ cmd.Reply("Failed to ban user:", err)
+ }
+
+}
+
+func cmdUnban(cmd *Command) {
+ if len(cmd.Args) != 1 {
+ cmd.Reply("Usage: /unban <user>")
+ return
+ }
+ _, err := cmd.Matrix.Client().UnbanUser(cmd.Room.MxRoom().ID, &mautrix.ReqUnbanUser{cmd.Args[0]})
+ if err != nil {
+ debug.Print("Error in unban call:", err)
+ cmd.Reply("Failed to unban user:", err)
+ }
+}
+
+func cmdKick(cmd *Command) {
+ if len(cmd.Args) < 1 {
+ cmd.Reply("Usage: /kick <user> <optional:reason>")
+ return
+ }
+ reason := "you are the weakest link, goodbye!"
+ if len(cmd.Args) >= 2 {
+ reason = strings.Join(cmd.Args[1:]," ")
+ }
+ _, err := cmd.Matrix.Client().KickUser(cmd.Room.MxRoom().ID, &mautrix.ReqKickUser{reason,cmd.Args[0]})
+ if err != nil {
+ debug.Print("Error in kick call:", err)
+ debug.Print("Failed to kick user:", err)
+ }
+
+}
+
func cmdJoin(cmd *Command) {
if len(cmd.Args) == 0 {
cmd.Reply("Usage: /join <room>")