FIX: Everything mentioned, except clubbing main.py and event_details.py

This commit is contained in:
Rachit Agrawal 2024-04-21 15:39:22 +00:00
parent d554b6f1fb
commit 23819baea7
7 changed files with 21 additions and 4 deletions

View File

@ -8,19 +8,22 @@
This script creates events across -
1. [Google Calendar](https://developersindia.in/events-calendar/)
2. [Discord](https://discord.com/channels/669880381649977354/)
---
### FIRST TIME SETUP
1. Get Python3 `sudo apt-get install python3 && python3 --version`
2. Install required packages `pip install -r packages.txt`
2. Install required packages `pip install -r requirements.txt`
3. Add respective tokens in the `.env` file
3.1 Discord Bot token (Get it from [Discord Developers portal](https://discord.com/developers/applications/)) (bot must have MANAGE_EVENT & CREATE_EVENT permission)
3.1 Discord Bot token [`DISCORD_BOT_TOKEN`] (Get it from [Discord Developers portal](https://discord.com/developers/applications/)) (bot must have MANAGE_EVENT & CREATE_EVENT permission)
3.2 Guild ID (developersIndia => 1229786646468362260)
3.2 Guild ID [`DISCORD_GUILD_ID`] (developersIndia => `1229786646468362260`)
3.3 Calender Id ['GOOGLE_CALENDER_ID'] (developerIndia => `9f1337e4154910eb1bdb3bfac32b88f69546468b1281a6db58f50a909df5049f@group.calendar.google.com`)
4. Connect Google Calender through [Google cloud Console](https://console.cloud.google.com/)

View File

@ -1,11 +1,16 @@
import os.path
import event_details as main
from dotenv import load_dotenv
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
load_dotenv()
calendar_id = os.getenv('GOOGLE_CALENDAR_ID')
SCOPES = ['https://www.googleapis.com/auth/calendar']
def create_event(name, description, location, date, start_time, end_time):
@ -47,7 +52,7 @@ def create_event(name, description, location, date, start_time, end_time):
},
}
event = service.events().insert(calendarId='primary', body=event).execute()
event = service.events().insert(calendarId=calendar_id, body=event).execute()
print('Google Calender: %s' % (event.get('htmlLink')))
return event

View File

@ -6,7 +6,16 @@
DISCORD_BOT_TOKEN = "TOKEN"
# -----------
# DISCORD SERVER ID (GUILD ID)
# developersIndia => 1229786646468362260
DISCORD_GUILD_ID = 1229786646468362260
# -----------
# CALANDER ID
# developersIndia => "9f1337e4154910eb1bdb3bfac32b88f69546468b1281a6db58f50a909df5049f@group.calendar.google.com"
GOOGLE_CALENDAR_ID = "9f1337e4154910eb1bdb3bfac32b88f69546468b1281a6db58f50a909df5049f@group.calendar.google.com"