Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from flowlauncher import FlowLauncher, FlowLauncherAPI
- import os
- from typing import List
- import json, os.path
- import copy
- RESULT_TEMPLATE = {
- "Title": "",
- "SubTitle": "",
- "IcoPath": "Images/app.ico",
- }
- ACTION_TEMPLATE = {
- "JsonRPCAction": {
- "method": "",
- "parameters": [],
- "dontHideAfterAction": False
- }
- }
- class Main(FlowLauncher):
- messages_queue = []
- def this_is_a_test_function(self, args):
- # log_path = os.path.realpath(__file__).replace(os.path.basename(__file__), '') + "ha-commander.log"
- fileTest = open("test.txt", "w")
- fileTest.write("This is a test function!\n")
- fileTest.write(str(args) + "\n")
- fileTest.close()
- # WoxAPI.change_query("ha " + title + " ",True)
- # FlowLauncherAPI.change_query("ha this is a test query lolololol", True)
- def sendNormalMess(self, title: str, subtitle: str):
- message = copy.deepcopy(RESULT_TEMPLATE)
- message["Title"] = title
- message["SubTitle"] = subtitle
- self.messages_queue.append(message)
- def sendActionMess(self, title: str, subtitle: str, method: str, value: List, dontHide: bool = True):
- # information
- message = copy.deepcopy(RESULT_TEMPLATE)
- message["Title"] = title
- message["SubTitle"] = subtitle
- # action
- action = copy.deepcopy(ACTION_TEMPLATE)
- action["JsonRPCAction"]["method"] = method
- action["JsonRPCAction"]["parameters"] = value
- action["JsonRPCAction"]["dontHideAfterAction"] = False
- message.update(action)
- self.messages_queue.append(message)
- def query(self, params: str) -> List[dict]:
- q = params.strip()
- args = q.split(" ")
- # self.sendNormalMess("Normal Message 1", "Subtitle 1: {}".format(args))
- # self.sendNormalMess("Normal Message 2", "Subtitle 2: {}".format(args))
- self.sendActionMess("Action Message 1", "Subtitle: Args: {}".format(args), "this_is_a_test_function", [args], False)
- self.sendActionMess("Action Message 2", "Subtitle: Args: {}".format(args), "Flow.Launcher.ChangeQuery", ["ha new test query", False], False)
- return self.messages_queue
- if __name__ == "__main__":
- Main()
Advertisement
Add Comment
Please, Sign In to add comment