File tree 4 files changed +141
-0
lines changed
4 files changed +141
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Use machinelearning to find the relevant emoji.
5
+ If your emojis are not rendering properly go to and install the emoji fonts at the following link:
6
+ https://github.com/eosrei/emojione-color-font
7
+ """
8
+
9
+ from albertv0 import *
10
+ import json
11
+ import os
12
+ import urllib .request
13
+ import urllib .parse
14
+ import urllib .error
15
+ import requests
16
+
17
+ __iid__ = "PythonInterface/v0.2"
18
+ __prettyname__ = "Dango Emoji"
19
+ __version__ = "1.0"
20
+ __trigger__ = "emoji "
21
+ __author__ = "David Britt"
22
+ __dependencies__ = []
23
+
24
+ icon_path = os .path .dirname (__file__ ) + "/emojicon.svg"
25
+ dangoUrl = "https://emoji.getdango.com/api/emoji"
26
+
27
+ def handleQuery (query ):
28
+ results = []
29
+ if query .isTriggered :
30
+
31
+ item = Item (
32
+ id = __prettyname__ ,
33
+ icon = icon_path ,
34
+ completion = query .rawString ,
35
+ text = __prettyname__ ,
36
+ actions = []
37
+ )
38
+
39
+ if len (query .string ) >= 2 :
40
+ try :
41
+ with requests .get (dangoUrl , params = {"q" : query .string }) as api_response :
42
+ json_data = json .loads (api_response .text )
43
+
44
+ all_emojis = []
45
+ for emoj in json_data ["results" ]:
46
+ all_emojis .append (emoj ["text" ])
47
+
48
+ string_emojis = '' .join (all_emojis )
49
+
50
+ results .append (Item (
51
+ id = __prettyname__ ,
52
+ icon = icon_path ,
53
+ text = string_emojis ,
54
+ actions = [
55
+ ClipAction ("Copy translation to clipboard" , string_emojis )
56
+ ]
57
+ ))
58
+
59
+ for emoj in json_data ["results" ]:
60
+ results .append (
61
+ Item (
62
+ id = __prettyname__ ,
63
+ icon = icon_path ,
64
+ text = str (emoj ["text" ]),
65
+ actions = [
66
+ ClipAction ("Copy translation to clipboard" , str (emoj ["text" ]))
67
+ ]
68
+ )
69
+ )
70
+
71
+ except urllib .error .URLError as urlerr :
72
+ print ("Troubleshoot internet connection: %s" % urlerr )
73
+ item .subtext = "Connection error"
74
+ return item
75
+ else :
76
+ item .subtext = "Search emojis!"
77
+ return item
78
+ return results
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Find relevant Kaomoji's using machine learning.
5
+ """
6
+
7
+ from albertv0 import *
8
+ import os
9
+ import json
10
+ import urllib .request
11
+ import urllib .parse
12
+ import urllib .error
13
+ import requests
14
+
15
+ __iid__ = "PythonInterface/v0.2"
16
+ __prettyname__ = "Dango Kaomoji"
17
+ __version__ = "1.0"
18
+ __trigger__ = "kao "
19
+ __author__ = "David Britt"
20
+ __dependencies__ = []
21
+
22
+ icon_path = os .path .dirname (__file__ ) + "/kaoicon.svg"
23
+ dangoUrl = "https://customer.getdango.com/dango/api/query/kaomoji"
24
+
25
+ def handleQuery (query ):
26
+ results = []
27
+
28
+ if query .isTriggered :
29
+
30
+ item = Item (
31
+ id = __prettyname__ ,
32
+ icon = icon_path ,
33
+ completion = query .rawString ,
34
+ text = __prettyname__ ,
35
+ actions = []
36
+ )
37
+
38
+ if len (query .string ) >= 2 :
39
+ try :
40
+ with requests .get (dangoUrl , params = {"q" : query .string }) as api_response :
41
+ json_data = json .loads (api_response .text )
42
+ for emoj in json_data ["items" ]:
43
+ results .append (
44
+ Item (
45
+ id = __prettyname__ ,
46
+ icon = icon_path ,
47
+ text = emoj ["text" ],
48
+ actions = [
49
+ ClipAction ("Copy translation to clipboard" , emoj ["text" ])
50
+ ]
51
+ )
52
+ )
53
+ except urllib .error .URLError as urlerr :
54
+ print ("Troubleshoot internet connection: %s" % urlerr )
55
+ item .subtext = "Connection error"
56
+ return item
57
+ else :
58
+ item .subtext = "Search emojis!"
59
+ return item
60
+
61
+ return results
You can’t perform that action at this time.
0 commit comments