mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-24 05:35:51 +00:00
feat: send chat command
This commit is contained in:
+13
-6
@@ -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,
|
||||
|
||||
@@ -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
|
||||
})()
|
||||
|
||||
+10
-7
@@ -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(() => {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<div class="mb-2">
|
||||
<div class="mb-4" v-for="command in commands">
|
||||
<input v-model.trim="command.text" class="rounded bg-gray-900 px-1 block w-full mb-1 font-fontin-regular" />
|
||||
<div class="flex justify-end">
|
||||
<div class="flex">
|
||||
<ui-toggle v-model="command.send" class="ml-1">{{ t('press Enter') }}</ui-toggle>
|
||||
<div class="flex-1"></div>
|
||||
<button @click="removeCommand(command)" class="mr-2 text-gray-500">{{ t('Remove') }}</button>
|
||||
<hotkey-input v-model="command.hotkey" class="w-48" />
|
||||
</div>
|
||||
@@ -31,7 +33,8 @@ export default defineComponent({
|
||||
addComand () {
|
||||
Config.store.commands.push({
|
||||
text: '',
|
||||
hotkey: null
|
||||
hotkey: null,
|
||||
send: true
|
||||
})
|
||||
},
|
||||
removeCommand (command: IConfig['commands'][number]) {
|
||||
@@ -45,7 +48,8 @@ export default defineComponent({
|
||||
<i18n>
|
||||
{
|
||||
"ru": {
|
||||
"Add command": "Добавить команду"
|
||||
"Add command": "Добавить команду",
|
||||
"press Enter": "нажимать Enter"
|
||||
}
|
||||
}
|
||||
</i18n>
|
||||
|
||||
Reference in New Issue
Block a user