In this section, we'll write an action that responds emojis.
To write an action, maybe these four methods you'll be used: HOT_EVENT, QUERY_ACTION, ACTION_CALLBACK, EXECUTED_CALLBACK.
This method triggered by user settings, maybe from hot corner, hotkey or cron express. See hot event type.
Request example json:
{
"method": "HOT_EVENT",
"body": {
"type": "HOTKEY"
}
}This is the main method for our results querying, in this method, we'll pass an action param to you in body, you need return an action result list.
Request example json:
{
"method": "QUERY_ACTION",
"body": {
"scene": "MAIN",
"originAction": "emoji abc",
"keyword": "emoji",
"args": [
{
"value": "abc",
"type": "STRING",
"strValue": "abc"
}
],
"sizeLimit": 10
}
}Response example json:
[
{
"actionId": "emoji",
"title": [
{
"value": "😃😃😃",
"type": "PLAIN_TITLE"
}
],
"result": "😃😃😃",
"callbacks": [
{
"label": "a-language-bundle-id",
"actionCallback": "action callback"
}
],
"executedCallback": "callback executed",
"shouldAssignBundle": true
}
]Field
shouldAssignBundleexplanation: indicates that the returned content should be translated by the bound language resources.
If user called your customized result callback, we'll pass the result and value to you.
Request example json:
{
"method": "ACTION_CALLBACK",
"body": {
"actionCallback": "action callback",
"result": "😃😃😃"
}
}If user called any of your result callback, we'll pass the result and value to you.
Request example json:
{
"method": "EXECUTED_CALLBACK",
"body": {
"executedCallback": "callback executed",
"result": "😃😃😃"
}
}In this example, we will respond with the same number of emojis based on the length of argument of user input.
In this example, you should build an executable binary file or write an executable shell script, you can get an argument from commandline.
And you can refer our sample code in commandline demo plugin.
In this example, you need expose an endpoint /action in your web server, we'll use post method to request you.
And you can refer our sample code in http demo plugin.
In this example we create an action file named action.py, and writing the following content:
In this example we create an action file named action.qlexpress, and writing the following content:
Action special in qlexpress: you can just return a string value, we'll convert to the following structure, otherwise you should use java.util.List to wrap the java.util.Map.
[
{
"actionId": "qlexpress",
"score": 100,
"logo": "logos/sine.png",
"result": "your returned string value",
"title": [
{
"value": "your returned string value",
"type": "PLAIN_TITLE"
}
],
"subtitle": "Copy Result To The Clipboard",
"callbacks": [
{
"actionMethod": "COPY_RESULT"
}
]
}
]Add the following content to plugin-spec.yml:
actions:
- keywords:
- clemoji
handler: "{entry}"actions:
- keywords:
- httpemoji
handler: "{entry}/action"actions:
- keywords:
- pyemoji
handler: ./action.pyactions:
- keywords:
- qlemoji
handler: ./action.qlexpress