This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands_creater.py
192 lines (119 loc) · 5.91 KB
/
commands_creater.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import getpass
def Arduino_commands():
# Arduino Commands
arduino_commands = open("commands_data/Arduino_commands.txt", "r").readlines()
arduino_command_names = []
arduino_cmd_key_and_value_dict = {} # Dictionary
for ard_comd in arduino_commands:
# Example List
#
# [on port three][03 : 1]
#
#
#
if ard_comd[0] == "#":
continue
elif ard_comd[0] != "#":
arduino_cmd_data_unrefined_1 = ard_comd.replace("\n","").split(" > ") # ["on port three"]["3 : 1"]
arduino_command_names += [arduino_cmd_data_unrefined_1[0]] # ["on port three"]
arduino_cmd_key_and_value = arduino_cmd_data_unrefined_1[1].split(" : ") # ["3"]["1"]
arduino_cmd_key = arduino_cmd_key_and_value[0] # "3"
arduino_cmd_value = arduino_cmd_key_and_value[1] # "1"
# Create Dictionary
print()
arduino_cmd_key_and_value_dict.update({arduino_cmd_data_unrefined_1[0]:{arduino_cmd_key:arduino_cmd_value}}) # {{"on port three":{"3":"1"}}}
return [arduino_command_names, arduino_cmd_key_and_value_dict]
def Bot_commands():
# bot Commands
bot_commands = open("commands_data/bot_commands.txt", "r").readlines()
bot_command_names = []
bot_system_command = []
bot_cmd_key_and_value = {} # Dictionary
for bot_comd in bot_commands:
# Example List
#
# Shutdown yourself : exit()
#
#
#
if bot_comd.startswith("#") == "#":
continue
elif bot_comd[0] != "#":
bot_cmd_data_unrefined_1 = bot_comd.replace("\n","").split(" : ") # ["Shutdown yourself"],["exit()"]
bot_command_names += [bot_cmd_data_unrefined_1[0]] # ["Shutdown yourself"]
# System commands list
bot_system_command += [bot_cmd_data_unrefined_1[1]] # ["exit()"]
# Create Dictionary
bot_cmd_key_and_value.update({bot_cmd_data_unrefined_1[0]:bot_cmd_data_unrefined_1[1]}) # {"Shutdown yourself":"exit()"}
return [bot_command_names, bot_system_command, bot_cmd_key_and_value]
def arduino_previous_pin_state():
# List of all pin states of arduino
arduino_pre_pin_state = open("commands_data/arduino_previous_pin_state.txt", "r").readlines()
arduino_pin_state_dict = {}
for pin_state in arduino_pre_pin_state:
if pin_state[0] == "#":
continue
elif pin_state[0] != "#":
# Example data
# "3 : 0" --> String Value
pin_num_and_state = pin_state.replace("\n", "").split(" : ") # result -> ["3", "0"]
arduino_pin_state_dict.update({pin_num_and_state[0]:pin_num_and_state[1]}) # {"3":"0"}
# Return the dictionary of pin number and it's state
#print(f"readed from file -> {arduino_pin_state_dict}")
return arduino_pin_state_dict # Dictionary {"key":"value"}
def ai_name_parse():
# Read the Name of the AI that you want to use in this project
ai_name_list = open("commands_data/ai_name.txt", "r").readlines()
ai_name_line_counter = 0
for ai_name_identifier in ai_name_list:
ai_name_line_counter += 1 # Count the unwanted lines from the ai_name.txt
if ai_name_identifier.startswith("ai_name"):
# if the line start sith ai_name then only
# the AI name is accepted
#
# Format -> "ai_name = F.R.I.D.A.Y"
ai_name = ai_name_identifier.replace("\n", "").split(" = ")
return(ai_name[1]) # Return : "F.R.I.D.A.Y"
else:
if ai_name_line_counter == len(ai_name_list):
# If no supported ai_name variable is setup
# the it will return "AI" as the name of AI
return("AI") # If "AI" as the name of the AI
else:
continue
def AI_name_calling_lst():
# List of supported name calling names for the AI
ai_name_calling_lst = open("commands_data/ai_calling_data.txt", "r").readlines()
ai_name_list = []
for ai_calling_name in ai_name_calling_lst:
if ai_calling_name[0] == "#":
continue
elif ai_calling_name[0] != "#":
ai_name_list += [ai_calling_name.replace("\n", "")]
else:
continue
# print(ai_name_list)
return ai_name_list # list of all calling names for the ai
# The name of the user using the device
# where this software is to be used
username = getpass.getuser()
def user_name():
# username = "Your desired username you want to set"
return username # Returns the username of the user
def banner():
# The banner that is to be used in the Project
print("""
██╗ ██╗ ██████╗ ███╗ ███╗███████╗ █████╗ ██╗
██║ ██║██╔═══██╗████╗ ████║██╔════╝ ██╔══██╗██║
███████║██║ ██║██╔████╔██║█████╗ █████╗ ███████║██║
██╔══██║██║ ██║██║╚██╔╝██║██╔══╝ ╚════╝ ██╔══██║██║
██║ ██║╚██████╔╝██║ ╚═╝ ██║███████╗ ██║ ██║██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═╝
Project is available on : https://github.com/Arijit-Bhowmick/HOME-AI
- BY
ARIJIT BHOWMICK [https://github.com/Arijit-Bhowmick]
MADHAV BHARGAVA [https://github.com/madhavbhargava]
VIDHI PATEL [https://github.com/VidhiPattel]
OSHEEN RAWAT [https://github.com/osheen-rawat]
PRATYUSHA GIRI [https://github.com/2002pratyusha]
""")