forked from kordood/ssutice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.py
54 lines (44 loc) · 1.38 KB
/
webhook.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
from const import FilePath
from misc.pickle_io import load_pickle, save_pickle
def webhook_io(**kwargs):
webhook_path = FilePath.webhook
webhooks = load_pickle(webhook_path)
if kwargs["func"] == "append":
webhooks[kwargs["name"]] = kwargs["url"]
elif kwargs["func"] == "retrieve":
print(webhooks[kwargs["name"]])
elif kwargs["func"] == "remove":
webhooks.pop(kwargs["name"])
else:
return False
save_pickle(webhooks, webhook_path)
return True
if __name__ == '__main__':
print("Select menu")
print("1: Appends webhook url")
print("2: Retrieves webhook url")
print("3: Removes webhook url")
menu = int(input())
if menu == 1:
print("name:")
name = str(input())
print("url:")
url = str(input())
param = {"func": "append", "name": name, "url": url}
webhook_io(**param)
elif menu == 2:
print("name:")
name = str(input())
param = {"func": "retrieve", "name": name}
webhook_io(**param)
elif menu == 3:
print("name:")
name = str(input())
print("Do you really REMOVE " + name + "? [YES/NO]")
yn = str(input()).upper()
if yn == "YES" or yn == "Y":
param = {"func": "remove", "name": name}
webhook_io(**param)
print("Done.")
else:
print("Canceled.")