diff options
Diffstat (limited to 'ui/commands.go')
-rw-r--r-- | ui/commands.go | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/ui/commands.go b/ui/commands.go index 0adbb61..c7f0301 100644 --- a/ui/commands.go +++ b/ui/commands.go @@ -41,7 +41,6 @@ import ( func cmdMe(cmd *Command) { text := strings.Join(cmd.Args, " ") go cmd.Room.SendMessage(mautrix.MsgEmote, text) - cmd.UI.Render() } // GradientTable from https://github.com/lucasb-eyer/go-colorful/blob/master/doc/gradientgen/gradientgen.go @@ -87,10 +86,9 @@ func makeRainbow(cmd *Command, msgtype mautrix.MessageType) { continue } color := rainbow.GetInterpolatedColorFor(float64(i) / float64(len(text))).Hex() - _, _ = fmt.Fprintf(&html, "<font color=\"%s\">%c</font>", color, char) + _, _ = fmt.Fprintf(&html, "<font data-mx-color=\"%[1]s\" color=\"%[1]s\">%[2]c</font>", color, char) } go cmd.Room.SendMessage(msgtype, html.String()) - cmd.UI.Render() } func cmdRainbow(cmd *Command) { @@ -103,7 +101,6 @@ func cmdRainbowMe(cmd *Command) { func cmdNotice(cmd *Command) { go cmd.Room.SendMessage(mautrix.MsgNotice, strings.Join(cmd.Args, " ")) - cmd.UI.Render() } func cmdAccept(cmd *Command) { @@ -141,6 +138,42 @@ func cmdID(cmd *Command) { cmd.Reply("The internal ID of this room is %s", cmd.Room.MxRoom().ID) } +type SelectReason string + +const ( + SelectReply SelectReason = "reply to" + SelectReact = "react to" + SelectRedact = "redact" +) + +func cmdReply(cmd *Command) { + cmd.Room.selecting = true + cmd.Room.selectReason = SelectReply + cmd.Room.selectContent = strings.Join(cmd.Args, " ") + cmd.Room.OnSelect(cmd.Room.MessageView().selected) +} + +func cmdRedact(cmd *Command) { + cmd.Reply("Not yet implemented 3:") + + // This needs to be implemented in RoomView's OnSelect method + //cmd.Room.selecting = true + //cmd.Room.selectReason = SelectRedact + //cmd.Room.OnSelect(cmd.Room.MessageView().selected) +} + +func cmdReact(cmd *Command) { + if len(cmd.Args) == 0 { + cmd.Reply("Usage: /react <reaction>") + return + } + + cmd.Room.selecting = true + cmd.Room.selectReason = SelectReact + cmd.Room.selectContent = strings.Join(cmd.Args, " ") + cmd.Room.OnSelect(cmd.Room.MessageView().selected) +} + func cmdTags(cmd *Command) { tags := cmd.Room.MxRoom().RawTags if len(cmd.Args) > 0 && cmd.Args[0] == "--internal" { @@ -284,31 +317,42 @@ func cmdUnknownCommand(cmd *Command) { } func cmdHelp(cmd *Command) { - cmd.Reply(`/help - Show the temporary help message. - -/quit - Quit gomuks. -/clearcache - Clear cache and quit gomuks. -/logout - Log out of Matrix. - -/me <message> - Send an emote message. -/rainbow <message> - Send a rainbow message (markdown not supported). - -/create [room name] - Create a room. -/pm <user id> <...> - Create a private chat with the given user(s). -/join <room address> - Join a room. -/leave - Leave the current room. - -/invite <user id> - Invite a user. + cmd.Reply(`# General +/help - Show this "temporary" help message. +/quit - Quit gomuks. +/clearcache - Clear cache and quit gomuks. +/logout - Log out of Matrix. +/toggle <thing> - Temporary command to toggle various UI features. + +Things: rooms, users, baremessages, images, typingnotif + +# Sending special messages +/me <message> - Send an emote message. +/notice <message> - Send a notice (generally used for bot messages). +/rainbow <message> - Send rainbow text (markdown not supported). +/rainbowme <message> - Send rainbow text in an emote. +/reply [text] - Reply to the selected message. +/react <reaction> - React to the selected message. +/redact - Redact the selected message. + +# Rooms +/pm <user id> <...> - Create a private chat with the given user(s). +/create [room name] - Create a room. + +/join <room> [server] - Join a room. +/accept - Accept the invite. +/reject - Reject the invite. + +/invite <user id> - Invite the given user to the room. +/roomnick <name> - Change your per-room displayname. +/tag <tag> <priority> - Add the room to <tag>. +/untag <tag> - Remove the room from <tag>. +/tags - List the tags the room is in. + +/leave - Leave the current room. /kick <user id> [reason] - Kick a user. /ban <user id> [reason] - Ban a user. -/unban <user id> - Unban a user. - -/send <room id> <type> <json> - Send a custom event to the given room. -/msend <type> <json> - Send a custom event to the current room. -/setstate <room id> <type> <key/-> <json> - Send a custom event to the given room. -/msetstate <type> <key/-> <json> - Send a custom event to the current room. - -/toggle <thing> - Temporary command to toggle various UI features.`) +/unban <user id> - Unban a user.`) } func cmdLeave(cmd *Command) { @@ -432,7 +476,6 @@ func cmdMSendEvent(cmd *Command) { } func cmdSendEvent(cmd *Command) { - debug.Print(cmd.Command, cmd.Args, len(cmd.Args)) if len(cmd.Args) < 3 { cmd.Reply("Usage: /send <room id> <event type> <content>") return @@ -440,7 +483,6 @@ func cmdSendEvent(cmd *Command) { roomID := cmd.Args[0] eventType := mautrix.NewEventType(cmd.Args[1]) rawContent := strings.Join(cmd.Args[2:], " ") - debug.Print(roomID, eventType, rawContent) var content interface{} err := json.Unmarshal([]byte(rawContent), &content) |