This commit is contained in:
Stefano Assenzo 2023-01-25 15:47:58 +00:00 committed by GitHub
commit 061d0bee7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 14 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ all.log
__pycache__
test.py
school_time.xlsx
venv

View File

@ -33,8 +33,14 @@ async def orario():
for day in document['School Subject']:
for i, subject in enumerate(document['School Subject'][day]):
if subject['Subject'] == "CALF1 LINGUA ITALIANA":
channel = bot.get_channel(1063753802638954519)
#await ctx.send(f"Subject found: {subject['Subject']} at index: {i}")
await channel.send(f"Hours school: {i}, Subject: {subject['Subject']}, Teacher: {subject['Teacher']}, Room: {subject['Room']}")
print(f"Subject found: {subject['Subject']} at index: {i}")
# 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")
await ctx.send(f"Subject found: {subject['Subject']} at index: {i}")
@bot.command()
async def testpy(ctx):
bot.loop.create_task(orario(ctx))
await ctx.send("testpy")
bot.run(DISCORD_TOKEN)

View File

@ -322,13 +322,12 @@ def update_time_school():
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
teacher = ws.cell(row=i, column=column+1).value
room = ws.cell(row=i, column=column+2)
room = ws.cell(row=i, column=column+2).value
if dont_repeat == 9:
check_repeat += 1 # 13
check_repeat += 1
if check_repeat == 5:
check_repeat = 0
dont_repeat = 0
#number = 1
else:
if day == "None":
if school_subject == 0: #If school subject is 0, add "null" in MongoDB
@ -462,7 +461,7 @@ def update_time_school():
collection_archive.update_one(
{ "_id": ObjectId(array_document_archive_school_time_table)},
{ "$set": {
"School Subject." + array_test[0] + "." + str(gagaga)+ ".Teacher": teacher,
"School Subject." + array_test[0] + "." + str(gagaga_teacher)+ ".Teacher": teacher,
}
}
)
@ -492,7 +491,7 @@ def update_time_school():
collection_archive.update_one(
{ "_id": ObjectId(array_document_archive_school_time_table)},
{ "$set": {
"School Subject." + array_test[0] + "." + str(gagaga)+ ".Teacher": teacher,
"School Subject." + array_test[0] + "." + str(gagaga_teacher)+ ".Teacher": teacher,
}
}
)
@ -510,7 +509,6 @@ def update_time_school():
if check_repeat_room == 5:
check_repeat_room = 0
dont_repeat_room = 0
#number = 1
else:
if day == "None":
if room == 0:
@ -529,14 +527,14 @@ def update_time_school():
collection.update_one(
{ "_id": ObjectId(array_document_school_time_table)},
{ "$set": {
"School Subject." + array_test[0] + "." + str(gagaga_teacher) + ".Room": room,
"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,
"School Subject." + array_test[0] + "." + str(gagaga_room)+ ".Room": room,
}
}
)
@ -559,14 +557,14 @@ def update_time_school():
collection.update_one(
{ "_id": ObjectId(array_document_school_time_table)},
{ "$set": {
"School Subject." + array_test[0] + "." + str(gagaga_teacher)+ ".Room": room,
"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,
"School Subject." + array_test[0] + "." + str(gagaga_room)+ ".Room": room,
}
}
)