Message actions are now customizable
MODIFY
shortcuts/shortcuts.go
shortcuts/shortcuts.go
@@ -15,6 +15,22 @@ import (
var (
globalScope = addScope("Application wide", "global", nil)
multilineTextInput = addScope("Multiline text input", "multiline_text_input", globalScope)
+ chatview = addScope("Chatview", "chatview", globalScope)
+
+ QuoteSelectedMessage = addShortcut("quote_selected_message", "Quote selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'q', tcell.ModNone))
+ EditSelectedMessage = addShortcut("edit_selected_message", "Edit selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'e', tcell.ModNone))
+ ReplySelectedMessage = addShortcut("reply_selected_message", "Reply to author selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'r', tcell.ModNone))
+ CopySelectedMessageLink = addShortcut("copy_selected_message_link", "Copy link to selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'l', tcell.ModNone))
+ CopySelectedMessage = addShortcut("copy_selected_message", "Copy content of selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'c', tcell.ModNone))
+ ToggleSelectedMessageSpoilers = addShortcut("toggle_selected_message_spoilers", "Toggle spoilers in selected message",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 's', tcell.ModNone))
+ DeleteSelectedMessage = addShortcut("toggle_selected_message_spoilers", "Toggle spoilers in selected message",
+ chatview, tcell.NewEventKey(tcell.KeyDelete, 0, tcell.ModNone))
ExpandSelectionToLeft = addShortcut("expand_selection_word_to_left", "Expand selection word to left",
multilineTextInput, tcell.NewEventKey(tcell.KeyLeft, 0, tcell.ModShift))

MODIFY
ui/window.go
ui/window.go
@@ -245,45 +245,43 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
window.chatView = NewChatView(window.session, window.session.State.User.ID)
window.chatView.SetOnMessageAction(func(message *discordgo.Message, event *tcell.EventKey) *tcell.EventKey {
- if event.Modifiers() == tcell.ModNone {
- if event.Rune() == 'q' {
+ if shortcuts.QuoteSelectedMessage.Equals(event) {
window.insertQuoteOfMessage(message)
return nil
}
- if event.Rune() == 'r' {
+ if shortcuts.ReplySelectedMessage.Equals(event) {
window.messageInput.SetText("@" + message.Author.Username + "#" + message.Author.Discriminator + " " + window.messageInput.GetText())
app.SetFocus(window.messageInput.GetPrimitive())
return nil
}
- if event.Rune() == 'l' {
+ if shortcuts.CopySelectedMessageLink.Equals(event) {
copyError := clipboard.WriteAll(fmt.Sprintf("<https://discordapp.com/channels/@me/%s/%s>", message.ChannelID, message.ID))
if copyError != nil {
window.ShowErrorDialog(fmt.Sprintf("Error copying message link: %s", copyError.Error()))
}
}
- if event.Key() == tcell.KeyDelete {
+ if shortcuts.DeleteSelectedMessage.Equals(event) {
if message.Author.ID == window.session.State.User.ID {
window.askForMessageDeletion(message.ID, true)
}
return nil
}
- if event.Rune() == 'e' {
+ if shortcuts.EditSelectedMessage.Equals(event) {
window.startEditingMessage(message)
return nil
}
- if event.Rune() == 'c' {
+ if shortcuts.CopySelectedMessage.Equals(event) {
copyError := clipboard.WriteAll(message.ContentWithMentionsReplaced())
if copyError != nil {
window.ShowErrorDialog(fmt.Sprintf("Error copying message: %s", copyError.Error()))
}
return nil
}
- }
return event
})

Message actions are now customizable