diff --git a/src/ipc/types.ts b/src/ipc/types.ts index 7c7636a6..44a256cc 100644 --- a/src/ipc/types.ts +++ b/src/ipc/types.ts @@ -24,6 +24,7 @@ export interface Config { commands: Array<{ text: string hotkey: string | null + send: boolean }> clientLog: string | null useOsGlobalShortcut: boolean @@ -81,22 +82,28 @@ export const defaultConfig: Config = { restoreClipboard: true, commands: [{ text: '/hideout', - hotkey: 'F5' + hotkey: 'F5', + send: true }, { text: '/exit', - hotkey: 'F9' + hotkey: 'F9', + send: true }, { text: '@last ty', - hotkey: null + hotkey: null, + send: true }, { text: '/invite @last', - hotkey: null + hotkey: null, + send: true }, { text: '/tradewith @last', - hotkey: null + hotkey: null, + send: true }, { text: '/hideout @last', - hotkey: null + hotkey: null, + send: true }], clientLog: null, useOsGlobalShortcut: true, diff --git a/src/main/config.ts b/src/main/config.ts index 56ccc5e4..26307dc8 100644 --- a/src/main/config.ts +++ b/src/main/config.ts @@ -100,6 +100,14 @@ export const config = (() => { config.configVersion = 4 } + if (config.configVersion < 5) { + config.commands.forEach(cmd => { + cmd.send = true + }) + + config.configVersion = 5 + } + store.store = config return store })() diff --git a/src/main/game-chat.ts b/src/main/game-chat.ts index 243ce49c..490742c0 100644 --- a/src/main/game-chat.ts +++ b/src/main/game-chat.ts @@ -12,7 +12,7 @@ const AUTO_CLEAR = [ '/' // Command ] -export function typeInChat (text: string) { +export function typeInChat (text: string, send: boolean) { const saved = clipboard.readText() if (text.startsWith(PLACEHOLDER_LAST)) { @@ -34,12 +34,15 @@ export function typeInChat (text: string) { } robotjs.keyTap('V', ['Ctrl']) - robotjs.keyTap('Enter') - // restore the last chat - robotjs.keyTap('Enter') - robotjs.keyTap('ArrowUp') - robotjs.keyTap('ArrowUp') - robotjs.keyTap('Escape') + + if (send) { + robotjs.keyTap('Enter') + // restore the last chat + robotjs.keyTap('Enter') + robotjs.keyTap('ArrowUp') + robotjs.keyTap('ArrowUp') + robotjs.keyTap('Escape') + } if (config.get('restoreClipboard')) { setTimeout(() => { diff --git a/src/main/shortcuts.ts b/src/main/shortcuts.ts index 6f99974a..8c57e9c8 100644 --- a/src/main/shortcuts.ts +++ b/src/main/shortcuts.ts @@ -93,7 +93,7 @@ function registerGlobal () { ), ...config.get('commands') .map(command => - shortcutCallback(command.hotkey, () => typeInChat(command.text)) + shortcutCallback(command.hotkey, () => typeInChat(command.text, command.send)) ) ].filter(a => Boolean(a.shortcut)) @@ -174,7 +174,7 @@ export function setupShortcuts () { const command = config.get('commands').find(c => c.hotkey === pressed) if (command) { shortcutCallback(pressed, () => { - typeInChat(command.text) + typeInChat(command.text, command.send) }).cb() } } diff --git a/src/web/settings/chat.vue b/src/web/settings/chat.vue index 62397791..cdc20e62 100644 --- a/src/web/settings/chat.vue +++ b/src/web/settings/chat.vue @@ -3,7 +3,9 @@