Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5cfb24f

Browse files
Merge pull request avinashkranjan#52 from sooryaprakash31/gmeet-bot
Added GoogleClassroom-Bot
2 parents bce01b6 + c4bba29 commit 5cfb24f

File tree

8 files changed

+249
-0
lines changed

8 files changed

+249
-0
lines changed

‎GoogleClassroom-Bot/README.MD‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
2+
<h1 align="center"> GoogleClassroom-Bot</h1>
3+
<p align="center"><br>
4+
This bot joins your classes for you on time automatically using your google classroom schedule and account credentials.<br></p>
5+
6+
- [Requirements](#requirements)
7+
- [Setup](#setup)
8+
- [Execution](#execution)
9+
- [Output](#output)
10+
- [Customization](#customization)
11+
- [Troubleshooting](#troubleshooting)
12+
- [Author](#author)
13+
14+
## Requirements
15+
16+
- Clone of this repository
17+
- [python3](https://www.python.org/downloads/)
18+
- [Firefox browser](https://www.mozilla.org/en-US/firefox/all/#product-desktop-release)
19+
- `pip install requirements.txt`
20+
21+
## Setup
22+
23+
1. `cd GoogleClassroom-Bot`
24+
2. Enter your account credentials in `config.ini`</br>
25+
Example:
26+
>```
27+
>[AUTH]
28+
>USERNAME=username@abc.com
29+
>PASSWORD=password
30+
>```
31+
3. Download geckodriver from [here](https://github.com/mozilla/geckodriver/releases) and place it in the folder
32+
4. Create a profile in Firefox and block the camera and microphone access for google meet.
33+
<img src="docs/images/Firefox_permissions.png" align="center" >
34+
35+
5. Get the path for the created profile using `about:profiles` in the firefox browser
36+
and include it here.
37+
```
38+
def login(self):
39+
profile = webdriver.FirefoxProfile('/path/to/the/created/profile')
40+
```
41+
6. Get the Course Names from your classroom
42+
<img src="docs/images/CourseName.png" align="center">
43+
44+
7. Insert the Course Name at the appropriate position in `schedule.csv`</br>
45+
Example:
46+
> CS16004-SemC
47+
> - Mon - 09:20
48+
> - Tue - 11:40
49+
> - Thu - 14:25
50+
></br>
51+
><table>
52+
<th>Day</th>
53+
<th>09:20</th>
54+
<th>11:40</th>
55+
<th>14:25</th>
56+
<tr>
57+
<td>Mon</td>
58+
<td>CS16004-SemC</td>
59+
<td></td>
60+
<td></td>
61+
</tr>
62+
<tr>
63+
<td>Tue</td>
64+
<td></td>
65+
<td>CS16004-SemC</td>
66+
<td></td>
67+
</tr>
68+
<tr>
69+
<td>Wed</td>
70+
<td></td>
71+
<td></td>
72+
<td></td>
73+
</tr>
74+
<tr>
75+
<td>Thu</td>
76+
<td></td>
77+
<td></td>
78+
<td>CS16004-SemC</td>
79+
</tr>
80+
<tr>
81+
<td>Fri</td>
82+
<td></td>
83+
<td></td>
84+
<td></td>
85+
</tr>
86+
</table>
87+
88+
- Repeat this for all the Courses to populate the `schedule.csv` with your schedule
89+
90+
## Execution
91+
1. `cd GoogleClassroom-Bot`
92+
2. `python3 gmeet_bot.py`
93+
3. `ctrl+c` will stop the execution
94+
95+
96+
## Output
97+
98+
- The program will run in the background.
99+
- When the current time hits one of the class timings,
100+
1. The program automatically fires up the browser.
101+
2. Logs in your account into google classroom.
102+
3. Finds the Course from `schedule.csv`.
103+
4. Joins the meeting using the `Meet Link` in the course room.
104+
5. After one hour, ends the meeting and closes the browser.
105+
106+
## Customization
107+
108+
1. Class Timings
109+
- Modify the class timings in source code and in the header of `schedule.csv`
110+
- Use 24-hour time format
111+
2. It is programmed to run for three classes per day. Modify it here by changing 2 to 'n'-1 for 'n' classes.
112+
```
113+
if self.count < 2:
114+
self.count = self.count + 1
115+
```
116+
117+
## Troubleshooting
118+
1. Google account must not be already logged in.
119+
2. `schedule.csv` must contain the exact course names.
120+
3. Slow internet connection may cause program to crash.
121+
122+
---
123+
## Author
124+
[Soorya Prakash](https://github.com/sooryaprakash31)

‎GoogleClassroom-Bot/config.ini‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[AUTH]
2+
USERNAME=
3+
PASSWORD=
280 KB
Loading[フレーム]
306 KB
Loading[フレーム]
87.7 KB
Loading[フレーム]

‎GoogleClassroom-Bot/gmeet_bot.py‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
from selenium import webdriver
2+
from time import sleep
3+
from configparser import ConfigParser
4+
from datetime import datetime
5+
import csv
6+
7+
config = ConfigParser()
8+
config.read('config.ini')
9+
username = config.get('AUTH', 'USERNAME')
10+
password = config.get('AUTH', 'PASSWORD')
11+
12+
classTime = ["09:20","11:40","14:25"]
13+
14+
class ClassAutomation():
15+
def __init__(self):
16+
self.count = 0
17+
self.findCount()
18+
#Runs endlessly and calls initClass method when it's class time
19+
while True:
20+
if datetime.now().strftime("%H:%M") in classTime:
21+
print(datetime.now().strftime("%H:%M"))
22+
self.initClass()
23+
sleep(30)
24+
25+
#Initiates Class
26+
def initClass(self):
27+
className = self.findClass()
28+
if className is None:
29+
return
30+
print("Initiating...")
31+
self.login()
32+
self.driver.find_element_by_xpath("//div[text()='{}']".format(className)).click()
33+
sleep(10)
34+
link=self.driver.find_element_by_partial_link_text("https://meet.google.com/lookup/").text
35+
self.driver.get(link)
36+
sleep(10)
37+
self.driver.find_element_by_xpath("//span[text()='Join now']").click()
38+
sleep(60*60)
39+
print("Quitting...")
40+
sleep(5)
41+
self.driver.quit()
42+
if self.count < 2:
43+
self.count = self.count + 1
44+
else:
45+
self.count = 0
46+
self.findCount()
47+
48+
#Returns the ClassName for the current time
49+
def findClass(self):
50+
with open("schedule.csv","r") as csvFile:
51+
reader = csv.DictReader(csvFile)
52+
for row in reader:
53+
if row["Day"]==datetime.now().strftime("%a"):
54+
return row[classTime[self.count]]
55+
return None
56+
#Determines the current time position in the classTime list
57+
def findCount(self):
58+
if self.findClass() is None:
59+
print("No Class Today")
60+
return
61+
currentTime=datetime.now().strftime("%H:%M")
62+
currentHour = int(currentTime.split(":")[0])
63+
currentMin = int(currentTime.split(":")[1])
64+
for i in classTime:
65+
if currentHour==int(i.split(":")[0]) and currentMin<int(i.split(":")[1]):
66+
self.count = classTime.index(i)
67+
print("Next Class at",classTime[self.count],"Today")
68+
break
69+
elif currentHour<int(i.split(":")[0]):
70+
self.count = classTime.index(i)
71+
print("Next Class at",classTime[self.count],"Today")
72+
break
73+
else:
74+
if classTime.index(i)==2:
75+
self.count=0
76+
print("Next Class at",classTime[self.count],"Tomorrow")
77+
break
78+
continue
79+
80+
#Logs into the google classroom with the account credentials
81+
def login(self):
82+
profile = webdriver.FirefoxProfile('/path/to/the/created/profile')
83+
self.driver = webdriver.Firefox(profile)
84+
self.driver.get("https://accounts.google.com/")
85+
sleep(2)
86+
try:
87+
self.driver.find_element_by_name("identifier").send_keys(username)
88+
sleep(1)
89+
except:
90+
self.driver.find_element_by_name("Email").send_keys(username)
91+
sleep(1)
92+
try:
93+
self.driver.find_element_by_id("identifierNext").click()
94+
sleep(4)
95+
except:
96+
self.driver.find_element_by_id("next").click()
97+
sleep(4)
98+
try:
99+
self.driver.find_element_by_name("password").send_keys(password)
100+
sleep(1)
101+
except:
102+
self.driver.find_element_by_name("Passwd").send_keys(password)
103+
sleep(1)
104+
try:
105+
self.driver.find_element_by_id("passwordNext").click()
106+
sleep(4)
107+
except:
108+
self.driver.find_element_by_id("trustDevice").click()
109+
self.driver.find_element_by_id("submit").click()
110+
sleep(4)
111+
self.driver.get("https://classroom.google.com/")
112+
sleep(6)
113+
114+
ClassAutomation()

‎GoogleClassroom-Bot/requirements.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
selenium==3.141.0
2+
urllib3==1.25.10

‎GoogleClassroom-Bot/schedule.csv‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Day,09:20,11:40,14:25
2+
Mon,,,
3+
Tue,,,
4+
Wed,,,
5+
Thu,,,
6+
Fri,,,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /