-
Notifications
You must be signed in to change notification settings - Fork 2
/
reply-input.jxa.js
41 lines (36 loc) · 986 Bytes
/
reply-input.jxa.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env osascript -l JavaScript
const App = Application.currentApplication();
App.includeStandardAdditions = true;
/**
* Create a path from multiple string segments.
* @param segments The string segments of the path to create.
* @returns string
*/
function $path(...segments) {
return segments.join('/').replace(/\s/g, '\\ ');
}
const INSTALL_DIR = $path(
App.systemAttribute('alfred_preferences'),
'workflows',
App.systemAttribute('alfred_workflow_uid'),
);
function run(argv) {
const dto = App.systemAttribute('alfred_mm_dto');
const { chat_title } = JSON.parse(dto);
return JSON.stringify({
items: [
{
title: `Reply to ${chat_title.split('with')[1].trim()}`,
subtitle: 'Press enter to send, or escape to cancel.',
arg: argv[0],
match: argv[0],
variables: {
alfred_mm_reply_body: argv[0],
},
icon: {
path: `${INSTALL_DIR}/send.png`,
},
},
],
});
}