Skip to content

Commit

Permalink
🔖 v0.0.1
Browse files Browse the repository at this point in the history
finish base finish funtion and feature.
  • Loading branch information
Zeroto521 committed May 11, 2020
1 parent 9a0e553 commit a109c44
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# vscode local history file
.history/

# python cache
__pycache__/
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Wox.Plugin.Bark

Bark for Wox.

![](assets/example.png)

## Bark

> Bark is an iOS App which allows you to push customed notifications to your iPhone.
More information about Bark for https://github.com/Finb/Bark.

## Attention

- You should input in your **device api key** to [constant.py](/bark/constant.py) before you key in the message.
- It is better to paste the message in Wox. If you input the message one by one, Wox would send the message one by one also. There are not **Enter** in Wox. `¯\_(ツ)_/¯ `

## Requirements

- Python3.x
- requests
Binary file added assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions bark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from .bark import bark
12 changes: 12 additions & 0 deletions bark/bark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-

import requests

from .constant import *


def bark(message: str) -> int:
url = api_url.format(key=key, message=message)
r = requests.post(url)

return r.status_code
4 changes: 4 additions & 0 deletions bark/constant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8

key = "" # key in you device api key
api_url = 'https://api.day.app/{key}/{message}'
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

from ui import Main

if __name__ == '__main__':
Main()
12 changes: 12 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ID": "1f036b5d3425435784522cad3ed669b3",
"ActionKeyword": "bark",
"Name": "Bark",
"Description": "Bark for Wox.",
"Author": "Zeroto521",
"Version": "0.0.1",
"Language": "python",
"Website": "https://github.com/Zeroto521/Wox.Plugin.Bark",
"IcoPath": "assets\\favicon.png",
"ExecuteFileName": "main.py"
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
8 changes: 8 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-

from ui import Main

if __name__ == '__main__':
t = Main()
res = t.query('test')
print(res)
3 changes: 3 additions & 0 deletions ui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from .ui import Main
8 changes: 8 additions & 0 deletions ui/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-


RESULT_TEMPLATE = {
'Title': '',
'SubTitle': '',
'IcoPath': 'assets/favicon.png',
}
41 changes: 41 additions & 0 deletions ui/ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-

import copy
import os
import sys
from typing import List
sys.path.append('../bark')

from bark import bark
from wox import Wox

from .template import *


class Main(Wox):

messages_queue = []

def sendNormalMess(self, title: str, subtitle: str):
message = copy.deepcopy(RESULT_TEMPLATE)
message['Title'] = title
message['SubTitle'] = subtitle

self.messages_queue.append(message)

def query(self, param: str) -> List[dict]:
param = param.strip()

if param:
status_code = bark(param)
self.sendNormalMess('Bark', 'Done.')

if status_code == 200:
self.sendNormalMess('Bark', 'Succeed.')
else:
self.sendNormalMess('Bark', 'Fail.')
else:
self.sendNormalMess(
'Bark', 'Input the message which you want to send your device.')

return self.messages_queue

0 comments on commit a109c44

Please sign in to comment.