-
Notifications
You must be signed in to change notification settings - Fork 6
/
Commands.py
91 lines (84 loc) · 3.12 KB
/
Commands.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from Authentication.Login import *
from Authentication.FaceDetection import *
def IfIn(words, text, opr="or"):
"""[It take a array of words and checks if the words are present in the text
and return their AND or OR relation mentioned in the arguments.]
Args:
words ([list of strings]): [The words to check if present in text]
text ([string]): [The simple string text]
opr (str, optional): [The logical realtion of booleans i.e. AND, OR]. Defaults to "or".
Returns:
[boolean]: [The relation of 'opr' with all the boolean of matches (word in text)]
"""
if opr=="or":
for word in words:
if word in text:
return True
return False
for word in words:
if word in text:
continue
return False
return True
def AskCRE(window=""):
say("Enter your credentials")
print("Enter your credentials")
# window.loginWindow()
name = input("Enter your Name: ")
Pass = input("Enter your password: ")
return name.upper(), Pass
def Command(text, window=""):
if IfIn(["log", "in"], text, "and") or "scan" in text:
name = detectFace()
if name != "Not Found":
try:
path, ListDirs = LogIN(name)
Loggedin(name)
except Exception as e:
say(e)
print(e)
return
else:
say("Facial Recognition failed...")
name, Pass = AskCRE(window)
try:
path, ListDirs = LogIN(name, Pass, False)
Loggedin(name)
except:
say("Ooopss, it seems you forgot your password.")
print("Ooopss, it seems you forgot your password.")
ListDirs.remove("CREs.txt")
Open_Noti(path, ListDirs)
if IfIn(["opportunity", "opportunities"], text):
# window.opportunitiesWindow()
dirs = os.listdir(OpportunityPath)
if not dirs:
say('No Notification found regarding opportunities')
else:
print(FunList(dirs))
say("Say the number of notification to open")
TEXT = speak()
N=getNum(TEXT)
OPEN(os.path.join(OpportunityPath, dirs[N-1]))
if IfIn(["public", "department", "departmental","notification"], text):
# window.notificationWindow()
dirs = os.listdir(DepartmentPath)
if not dirs:
say('No Public Notification found')
else:
print(FunList(dirs))
say("Say the number of notification to open")
TEXT = speak()
N=getNum(TEXT)
OPEN(os.path.join(DepartmentPath, dirs[N-1]))
if IfIn(["society", "societies"], text):
# window.eventsWindow()
dirs = os.listdir(SocietyPath)
if not dirs:
say('No Updates regarding societies')
else:
print(FunList(dirs))
say("Say the number of notification to open")
TEXT = speak()
N=getNum(TEXT)
OPEN(os.path.join(SocietyPath, dirs[N-1]))