Compare commits
No commits in common. "88a5bcdb33abad7af962534d9309671692f51b81" and "bf041c0bbb1997ae492f5e6c1260f5563727c64f" have entirely different histories.
88a5bcdb33
...
bf041c0bbb
|
@ -4,5 +4,4 @@ geckodriver.log
|
||||||
all.log
|
all.log
|
||||||
__pycache__
|
__pycache__
|
||||||
test.py
|
test.py
|
||||||
school_time.xlsx
|
school_time.xlsx
|
||||||
venv
|
|
|
@ -11,7 +11,9 @@ load_dotenv() # Load .env file
|
||||||
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') # Discord token
|
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') # Discord token
|
||||||
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') # Password for MongoDB
|
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') # Password for MongoDB
|
||||||
URL_MONGODB = os.getenv('URL_MONGODB') # URL for MongoDB
|
URL_MONGODB = os.getenv('URL_MONGODB') # URL for MongoDB
|
||||||
mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB # URL for MongoDB (with password)
|
mongo_url = "mongodb+srv://elci:" + \
|
||||||
|
urllib.parse.quote_plus(PASSWORD_MONGODB) + \
|
||||||
|
URL_MONGODB # URL for MongoDB (with password)
|
||||||
client = pymongo.MongoClient(mongo_url) # Connect to MongoDB
|
client = pymongo.MongoClient(mongo_url) # Connect to MongoDB
|
||||||
database = client["website-class"] # Database name
|
database = client["website-class"] # Database name
|
||||||
# Collection school time table current
|
# Collection school time table current
|
||||||
|
@ -34,7 +36,7 @@ async def orario(ctx):
|
||||||
# Send a message on channel #general with the subject found and the index of the subject
|
# Send a message on channel #general with the subject found and the index of the subject
|
||||||
channel = bot.get_channel(1063753802638954519).send("bot is online")
|
channel = bot.get_channel(1063753802638954519).send("bot is online")
|
||||||
await ctx.send(f"Subject found: {subject['Subject']} at index: {i}")
|
await ctx.send(f"Subject found: {subject['Subject']} at index: {i}")
|
||||||
print(f"Subject: {subject['Subject'], Teacher: {subject['Teacher'], Room: {subject['Room']")
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def testpy(ctx):
|
async def testpy(ctx):
|
||||||
|
|
|
@ -42,252 +42,204 @@ def update_time_school():
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"Tuesday": [
|
"Tuesday": [
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"Wednesday": [
|
"Wednesday": [
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"Thursday": [
|
"Thursday": [
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"Friday": [
|
"Friday": [
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"Saturday": [
|
"Saturday": [
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Subject": "null",
|
"Subject": "null",
|
||||||
"Teacher": "null",
|
"Teacher": "null",
|
||||||
"Room": "null",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -297,14 +249,10 @@ def update_time_school():
|
||||||
x = collection_archive.insert_one(mydict) # Add collection on collection (archive-school-time-table)
|
x = collection_archive.insert_one(mydict) # Add collection on collection (archive-school-time-table)
|
||||||
check_repeat = 0
|
check_repeat = 0
|
||||||
check_repeat_teacher = 0
|
check_repeat_teacher = 0
|
||||||
check_repeat_room = 0
|
|
||||||
dont_repeat = 0
|
dont_repeat = 0
|
||||||
dont_repeat_teacher = 0
|
dont_repeat_teacher = 0
|
||||||
dont_repeat_room = 0
|
|
||||||
gagaga_teacher = 0
|
gagaga_teacher = 0
|
||||||
gagaga_room = 0
|
|
||||||
number_teacher = 1
|
number_teacher = 1
|
||||||
number_room = 1
|
|
||||||
number = 1
|
number = 1
|
||||||
current_day = None
|
current_day = None
|
||||||
day_counter = 0
|
day_counter = 0
|
||||||
|
@ -322,13 +270,12 @@ def update_time_school():
|
||||||
day = str(ws.cell(row=i, column=3).value) # Get day from excel file
|
day = str(ws.cell(row=i, column=3).value) # Get day from excel file
|
||||||
school_subject = ws.cell(row=i, column=column).value # Get school subject from excel file
|
school_subject = ws.cell(row=i, column=column).value # Get school subject from excel file
|
||||||
teacher = ws.cell(row=i, column=column+1).value
|
teacher = ws.cell(row=i, column=column+1).value
|
||||||
room = ws.cell(row=i, column=column+2).value
|
|
||||||
print(room)
|
|
||||||
if dont_repeat == 9:
|
if dont_repeat == 9:
|
||||||
check_repeat += 1
|
check_repeat += 1 # 13
|
||||||
if check_repeat == 5:
|
if check_repeat == 5:
|
||||||
check_repeat = 0
|
check_repeat = 0
|
||||||
dont_repeat = 0
|
dont_repeat = 0
|
||||||
|
#number = 1
|
||||||
else:
|
else:
|
||||||
if day == "None":
|
if day == "None":
|
||||||
if school_subject == 0: #If school subject is 0, add "null" in MongoDB
|
if school_subject == 0: #If school subject is 0, add "null" in MongoDB
|
||||||
|
@ -462,7 +409,7 @@ def update_time_school():
|
||||||
collection_archive.update_one(
|
collection_archive.update_one(
|
||||||
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
||||||
{ "$set": {
|
{ "$set": {
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_teacher)+ ".Teacher": teacher,
|
"School Subject." + array_test[0] + "." + str(gagaga)+ ".Subject": school_subject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -492,7 +439,7 @@ def update_time_school():
|
||||||
collection_archive.update_one(
|
collection_archive.update_one(
|
||||||
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
||||||
{ "$set": {
|
{ "$set": {
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_teacher)+ ".Teacher": teacher,
|
"School Subject." + array_test[0] + "." + str(gagaga)+ ".Subject": school_subject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -504,77 +451,4 @@ def update_time_school():
|
||||||
if gagaga_teacher == 8:
|
if gagaga_teacher == 8:
|
||||||
gagaga_teacher = 0
|
gagaga_teacher = 0
|
||||||
|
|
||||||
#Search room school
|
|
||||||
if dont_repeat_room == 9:
|
|
||||||
check_repeat_room += 1
|
|
||||||
if check_repeat_room == 5:
|
|
||||||
check_repeat_room = 0
|
|
||||||
dont_repeat_room = 0
|
|
||||||
else:
|
|
||||||
if day == "None":
|
|
||||||
if room == 0:
|
|
||||||
number_room += 1
|
|
||||||
gagaga_room += 1
|
|
||||||
dont_repeat_room += 1
|
|
||||||
if number_room == 9:
|
|
||||||
number_room = 1
|
|
||||||
if gagaga_room == 9:
|
|
||||||
gagaga_room = 0
|
|
||||||
else:
|
|
||||||
find_document_school_time_table = list(collection.find({}, {"Date": long_date}))
|
|
||||||
find_document_archive_school_time_table = list(collection_archive.find({}, {"Date": long_date}))
|
|
||||||
array_document_school_time_table = find_document_school_time_table[0]["_id"]
|
|
||||||
array_document_archive_school_time_table = find_document_archive_school_time_table[0]["_id"]
|
|
||||||
collection.update_one(
|
|
||||||
{ "_id": ObjectId(array_document_school_time_table)},
|
|
||||||
{ "$set": {
|
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_room) + ".Room": room,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
collection_archive.update_one(
|
|
||||||
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
|
||||||
{ "$set": {
|
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_room)+ ".Room": room,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
number_room += 1
|
|
||||||
gagaga_room += 1
|
|
||||||
dont_repeat_room += 1
|
|
||||||
if number_room == 9:
|
|
||||||
number_room = 1
|
|
||||||
if gagaga_room == 8:
|
|
||||||
gagaga_room = 0
|
|
||||||
else:
|
|
||||||
datetime_obj = datetime.datetime.strptime(day, "%Y-%m-%d %H:%M:%S").strftime("%d %m %Y")
|
|
||||||
convert_date_to_day = datetime.datetime.strptime(datetime_obj, '%d %m %Y').strftime('%A')
|
|
||||||
array_test = []
|
|
||||||
array_test.append(convert_date_to_day)
|
|
||||||
find_document_school_time_table = list(collection.find({}, {"Date": long_date}))
|
|
||||||
find_document_archive_school_time_table = list(collection_archive.find({}, {"Date": long_date}))
|
|
||||||
array_document_school_time_table = find_document_school_time_table[0]["_id"]
|
|
||||||
array_document_archive_school_time_table = find_document_archive_school_time_table[0]["_id"]
|
|
||||||
collection.update_one(
|
|
||||||
{ "_id": ObjectId(array_document_school_time_table)},
|
|
||||||
{ "$set": {
|
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_room)+ ".Room": room,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
collection_archive.update_one(
|
|
||||||
{ "_id": ObjectId(array_document_archive_school_time_table)},
|
|
||||||
{ "$set": {
|
|
||||||
"School Subject." + array_test[0] + "." + str(gagaga_room)+ ".Room": room,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
number_room += 1
|
|
||||||
gagaga_room += 1
|
|
||||||
dont_repeat_room += 1
|
|
||||||
if number_room == 9:
|
|
||||||
number_room = 1
|
|
||||||
if gagaga_room == 8:
|
|
||||||
gagaga_room = 0
|
|
||||||
|
|
||||||
update_time_school()
|
update_time_school()
|
Loading…
Reference in New Issue