forked from Aditi-Asati/online-class-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
class bot.py
79 lines (68 loc) · 2.64 KB
/
class bot.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
import pyautogui as p, webbrowser
from win10toast import ToastNotifier
from datetime import datetime
from time import sleep
from os import startfile, getlogin
import pandas as pd
# todo click on google meet mute and camera off button
def zoom_meeting(meeting_id:str, password:str):
"""Joins zoom meeting with provided meeting_id and password."""
startfile(f"C:\\Users\\{getlogin()}\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")
sleep(5)
p.click(530, 281)
sleep(2)
p.click(651, 323)
sleep(1)
p.typewrite(meeting_id)
p.press('enter')
sleep(3)
p.typewrite(password)
p.press('enter')
exit()
def google_meet(meeting_link:str):
"""
Joins meetings held in google_meet.
"""
wb = webbrowser.Chrome(r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
wb.open_new_tab(meeting_link)
sleep(5)
p.click(410,583)
p.click(487,583)
quit()
def alert(lecture:str):
"""
Alerts the user on the event of a class.
"""
toaster = ToastNotifier()
toaster.show_toast("Class Notification", f"{lecture} class right now. Joining the meeting...")
def join_class():
"""
Checks if there is any class on a particular date by extracting data from timetable.xlsx.
"""
timetable = pd.read_excel(r"timetable.xlsx", sheet_name=datetime.now().strftime("%A"))
current_time = datetime.now().strftime("%H:%M")
current_hour = int(datetime.now().strftime("%H"))
current_minute = int(datetime.now().strftime("%M"))
for _, item in timetable.iterrows():
class_hour = int(item["Class Time"].split(":")[0])
class_minute = int(item["Class Time"].split(":")[-1])
if class_hour == current_hour and current_minute in range(class_minute, class_minute + 10):
class_name = item["Class Name"]
joining_mode = item["Mode"].capitalize()
if joining_mode not in ["Zoom", "Meet"]:
raise Exception("Improper data filled in timetable.xlsx! Mode can either be 'Zoom' or 'Meet'.")
if joining_mode == "Zoom":
meeting_id = item["Meeting ID/Link"]
meeting_password = item["Meeting Password"]
alert(class_name)
zoom_meeting(str(meeting_id), str(meeting_password))
elif joining_mode == "Meet":
meeting_link = item["Meeting ID/Link"]
alert(class_name)
google_meet(str(meeting_link))
else:
print(f"No class right now at {current_time}.")
if __name__ == "__main__":
while 1:
join_class()
sleep(30)