Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions GoogleClassroom-Bot/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@

<h1 align="center"> GoogleClassroom-Bot</h1>
<p align="center"><br>
This bot joins your classes for you on time automatically using your google classroom schedule and account credentials.<br></p>

- [Requirements](#requirements)
- [Setup](#setup)
- [Execution](#execution)
- [Output](#output)
- [Customization](#customization)
- [Troubleshooting](#troubleshooting)
- [Author](#author)

## Requirements

- Clone of this repository
- [python3](https://www.python.org/downloads/)
- [Firefox browser](https://www.mozilla.org/en-US/firefox/all/#product-desktop-release)
- `pip install requirements.txt`

## Setup

1. `cd GoogleClassroom-Bot`
2. Enter your account credentials in `config.ini`</br>
Example:
>```
>[AUTH]
>USERNAME=username@abc.com
>PASSWORD=password
>```
3. Download geckodriver from [here](https://github.com/mozilla/geckodriver/releases) and place it in the folder
4. Create a profile in Firefox and block the camera and microphone access for google meet.
<img src="docs/images/Firefox_permissions.png" align="center" >

5. Get the path for the created profile using `about:profiles` in the firefox browser
and include it here.
```
def login(self):
profile = webdriver.FirefoxProfile('/path/to/the/created/profile')
```
6. Get the Course Names from your classroom
<img src="docs/images/CourseName.png" align="center">

7. Insert the Course Name at the appropriate position in `schedule.csv`</br>
Example:
> CS16004-SemC
> - Mon - 09:20
> - Tue - 11:40
> - Thu - 14:25
></br>
><table>
<th>Day</th>
<th>09:20</th>
<th>11:40</th>
<th>14:25</th>
<tr>
<td>Mon</td>
<td>CS16004-SemC</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tue</td>
<td></td>
<td>CS16004-SemC</td>
<td></td>
</tr>
<tr>
<td>Wed</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Thu</td>
<td></td>
<td></td>
<td>CS16004-SemC</td>
</tr>
<tr>
<td>Fri</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

- Repeat this for all the Courses to populate the `schedule.csv` with your schedule

## Execution
1. `cd GoogleClassroom-Bot`
2. `python3 gmeet_bot.py`
3. `ctrl+c` will stop the execution


## Output

- The program will run in the background.
- When the current time hits one of the class timings,
1. The program automatically fires up the browser.
2. Logs in your account into google classroom.
3. Finds the Course from `schedule.csv`.
4. Joins the meeting using the `Meet Link` in the course room.
5. After one hour, ends the meeting and closes the browser.

## Customization

1. Class Timings
- Modify the class timings in source code and in the header of `schedule.csv`
- Use 24-hour time format
2. It is programmed to run for three classes per day. Modify it here by changing 2 to 'n'-1 for 'n' classes.
```
if self.count < 2:
self.count = self.count + 1
```

## Troubleshooting
1. Google account must not be already logged in.
2. `schedule.csv` must contain the exact course names.
3. Slow internet connection may cause program to crash.

---
## Author
[Soorya Prakash](https://github.com/sooryaprakash31)
3 changes: 3 additions & 0 deletions GoogleClassroom-Bot/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[AUTH]
USERNAME=
PASSWORD=
Binary file added GoogleClassroom-Bot/docs/images/CourseName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions GoogleClassroom-Bot/gmeet_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
from selenium import webdriver
from time import sleep
from configparser import ConfigParser
from datetime import datetime
import csv

config = ConfigParser()
config.read('config.ini')
username = config.get('AUTH', 'USERNAME')
password = config.get('AUTH', 'PASSWORD')

classTime = ["09:20","11:40","14:25"]

class ClassAutomation():
def __init__(self):
self.count = 0
self.findCount()
#Runs endlessly and calls initClass method when it's class time
while True:
if datetime.now().strftime("%H:%M") in classTime:
print(datetime.now().strftime("%H:%M"))
self.initClass()
sleep(30)

#Initiates Class
def initClass(self):
className = self.findClass()
if className is None:
return
print("Initiating...")
self.login()
self.driver.find_element_by_xpath("//div[text()='{}']".format(className)).click()
sleep(10)
link=self.driver.find_element_by_partial_link_text("https://meet.google.com/lookup/").text
self.driver.get(link)
sleep(10)
self.driver.find_element_by_xpath("//span[text()='Join now']").click()
sleep(60*60)
print("Quitting...")
sleep(5)
self.driver.quit()
if self.count < 2:
self.count = self.count + 1
else:
self.count = 0
self.findCount()

#Returns the ClassName for the current time
def findClass(self):
with open("schedule.csv","r") as csvFile:
reader = csv.DictReader(csvFile)
for row in reader:
if row["Day"]==datetime.now().strftime("%a"):
return row[classTime[self.count]]
return None
#Determines the current time position in the classTime list
def findCount(self):
if self.findClass() is None:
print("No Class Today")
return
currentTime=datetime.now().strftime("%H:%M")
currentHour = int(currentTime.split(":")[0])
currentMin = int(currentTime.split(":")[1])
for i in classTime:
if currentHour==int(i.split(":")[0]) and currentMin<int(i.split(":")[1]):
self.count = classTime.index(i)
print("Next Class at",classTime[self.count],"Today")
break
elif currentHour<int(i.split(":")[0]):
self.count = classTime.index(i)
print("Next Class at",classTime[self.count],"Today")
break
else:
if classTime.index(i)==2:
self.count=0
print("Next Class at",classTime[self.count],"Tomorrow")
break
continue

#Logs into the google classroom with the account credentials
def login(self):
profile = webdriver.FirefoxProfile('/path/to/the/created/profile')
self.driver = webdriver.Firefox(profile)
self.driver.get("https://accounts.google.com/")
sleep(2)
try:
self.driver.find_element_by_name("identifier").send_keys(username)
sleep(1)
except:
self.driver.find_element_by_name("Email").send_keys(username)
sleep(1)
try:
self.driver.find_element_by_id("identifierNext").click()
sleep(4)
except:
self.driver.find_element_by_id("next").click()
sleep(4)
try:
self.driver.find_element_by_name("password").send_keys(password)
sleep(1)
except:
self.driver.find_element_by_name("Passwd").send_keys(password)
sleep(1)
try:
self.driver.find_element_by_id("passwordNext").click()
sleep(4)
except:
self.driver.find_element_by_id("trustDevice").click()
self.driver.find_element_by_id("submit").click()
sleep(4)
self.driver.get("https://classroom.google.com/")
sleep(6)

ClassAutomation()
2 changes: 2 additions & 0 deletions GoogleClassroom-Bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
selenium==3.141.0
urllib3==1.25.10
6 changes: 6 additions & 0 deletions GoogleClassroom-Bot/schedule.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Day,09:20,11:40,14:25
Mon,,,
Tue,,,
Wed,,,
Thu,,,
Fri,,,