-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
75 lines (64 loc) · 2.44 KB
/
app.py
File metadata and controls
75 lines (64 loc) · 2.44 KB
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
73
74
75
from InquirerPy import inquirer
import modules.menuActions.menuActions as actions
import modules.types.types as types
from InquirerPy.utils import color_print
from modules.helpers.helpers import initialize
from modules.static.constants import GITHUB_ADDRESS
NOT_IMPLEMENTED_OPTION_ERROR: types.Response = {
"error": {"message": "Option is not implemented yet, coming soon!", "code": 503},
"isSuccess": False,
}
def main():
try:
initialize()
except Exception as e:
color_print(
formatted_text=[
(
"red",
"An error occurred during the initialization of the app.\nThe exact error message is:\n",
),
("white", str(e)),
("white", "\n"),
(
"red",
f"If you think there is anything wrong with the code, feel free to open an issue on the project’s GitHub.\n Github: {GITHUB_ADDRESS} \nExited.",
),
]
)
return
options = {
"Add a Telegram User": actions.add_tg_user_action,
"Show Telegram Users": actions.show_tg_users_action,
"Delete a Telegram User": actions.delete_tg_user_action,
"Add a Message": actions.add_messages_action,
"Show Messages": actions.show_messages_action,
"Delete a Message": actions.delete_messages_action,
"Start Auto Messaging": actions.start_auto_messaging_action,
"Github": actions.show_github_action,
"Exit": lambda: None,
}
while True:
action = inquirer.select(
message="Select an action:",
choices=options.keys(),
).execute()
if action == "Exit":
color_print(formatted_text=[("red", "Exited")])
break
response: types.Response = options[action]()
if not response["isSuccess"]:
color_print(
formatted_text=[
("red", "Error: " + response["error"]["message"]),
("white", "\n"),
(
"red",
"If you think there is anything wrong with the code, feel free to open an issue on the project’s GitHub which you can find in Github option in the menu.",
),
]
)
else:
color_print(formatted_text=[("green", "Done!")])
if __name__ == "__main__":
main()