Skip to content

Commit

Permalink
Remove Declined Events
Browse files Browse the repository at this point in the history
  • Loading branch information
leoherzog authored May 25, 2021
1 parent d98a63f commit 94c5f0a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cal.30s.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def main():
events = []
for cal in ids:
thisCalInList = service.calendarList().get(calendarId=cal['id']).execute() # pylint: disable=no-member
thisCalsEvents = service.events().list(calendarId=cal['id'], timeMin=beginningOfDay, timeMax=endOfDay, maxResults=50, singleEvents=True).execute().get('items', []) # pylint: disable=no-member
thisCalsEvents = service.events().list(calendarId=cal['id'], timeMin=beginningOfDay, timeMax=endOfDay, maxResults=50, maxAttendees=1, singleEvents=True).execute().get('items', []) # pylint: disable=no-member
for event in thisCalsEvents:
event['summary'] = html.escape(event.get('summary', '')).replace('|', '∣') # reserved character for bitbar/argos. replace "vertical bar" with "divides" unicode character.
event['icon'] = cal['icon']
Expand All @@ -76,11 +76,14 @@ def main():
event['color'] = colors.get('calendar', {}).get(thisCalInList.get('colorId')).get('background')
events = events + thisCalsEvents

# sort by start time
events.sort(key = lambda event : event['start'].get('dateTime', event['start'].get('date')))

# remove names in the filter
events = [x for x in events if not x.get('summary') in eventNamesToFilter]

# remove events that have been declined, if attendees key exists
events = [x for x in events if not x.get('attendees') or x.get('attendees')[0].get('responseStatus', '') != 'declined']

# sort by start time
events.sort(key = lambda event : event['start'].get('dateTime', event['start'].get('date')))

now = datetime.datetime.now().astimezone()

Expand Down Expand Up @@ -210,4 +213,4 @@ def findMeetingId(text):
return None

if __name__ == '__main__':
main()
main()

0 comments on commit 94c5f0a

Please sign in to comment.