-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·72 lines (56 loc) · 1.99 KB
/
main.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import gi, requests, json
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
token="YOUR_TOKEN"
class UnifiedbanGUIWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="unified/ban GUI")
self.set_size_request(400, 250)
self.set_position(Gtk.WindowPosition.CENTER)
settings = Gtk.Settings.get_default()
settings.set_property("gtk-application-prefer-dark-theme", True)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
vbox.set_border_width(20)
self.add(vbox)
self.entry = Gtk.Entry()
self.entry.set_placeholder_text("Enter User_ID and press Enter")
self.entry.connect("activate", self.on_entry_activate)
vbox.add(self.entry)
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_hexpand(True)
scrolledwindow.set_vexpand(True)
vbox.add(scrolledwindow)
textview = Gtk.TextView()
textview.set_border_width(10)
self.textbuffer = textview.get_buffer()
self.textbuffer.set_text("Wait for input ..")
scrolledwindow.add(textview)
textview.grab_focus()
self.add(vbox)
def on_entry_activate(self, entry):
api_url = "https://api.unifiedban.solutions/blacklist/check/%s" % self.entry.get_text()
response = requests.get(
api_url, headers = {
'Authorization': token
}
)
try:
self.textbuffer.set_text(
json.dumps(
json.loads(response.text),
sort_keys=True,
indent=4
)
)
except:
self.textbuffer.set_text(
json.dumps(
'{"Error": "No data"}',
sort_keys=True,
indent=4
)
)
win = UnifiedbanGUIWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()