Fix google calendar event sending, fixes #1. Readme updates.
This commit is contained in:
parent
0f702ff8ec
commit
50ada1d6d7
|
@ -3,7 +3,7 @@ FROM python:3
|
|||
WORKDIR /bot
|
||||
RUN pip install pipenv
|
||||
COPY Pipfile .
|
||||
RUN pipenv install --skip-lock --system
|
||||
RUN pipenv install --pre --system
|
||||
|
||||
COPY bot.py .
|
||||
COPY modules modules
|
||||
|
|
3
Pipfile
3
Pipfile
|
@ -18,3 +18,6 @@ pylint = "*"
|
|||
|
||||
[requires]
|
||||
python_version = "3.7"
|
||||
|
||||
[pipenv]
|
||||
allow_prereleases = true
|
||||
|
|
|
@ -119,12 +119,13 @@ Example:
|
|||
|
||||
## Running on host
|
||||
|
||||
Run something like:
|
||||
Run something like (tested on Ubuntu):
|
||||
|
||||
``` bash
|
||||
pip3 install pipenv
|
||||
sudo apt install python3-pip
|
||||
sudo pip3 install pipenv
|
||||
pipenv shell
|
||||
pipenv install
|
||||
pipenv install --pre
|
||||
MATRIX_USER="@user:matrix.org" MATRIX_ACCESS_TOKEN="MDAxOGxvYlotofcharacters53CgYAYFgo" MATRIX_SERVER="https://matrix.org" JOIN_ON_INVITE=True python3 bot.py
|
||||
```
|
||||
|
||||
|
|
|
@ -115,7 +115,8 @@ class MatrixModule:
|
|||
|
||||
if len(events) == 0:
|
||||
await bot.send_text(room, 'No events found.')
|
||||
else:
|
||||
|
||||
if len(events):
|
||||
print(f'Found {len(events)} events')
|
||||
await self.send_events(bot, events, room)
|
||||
|
||||
|
@ -137,15 +138,15 @@ class MatrixModule:
|
|||
|
||||
def list_today(self, calid):
|
||||
startTime = datetime.datetime.utcnow()
|
||||
startTime = startTime - datetime.timedelta(hours=startTime.hour, minutes=startTime.minute)
|
||||
startTime = startTime.replace(hour = 0, minute = 0, second = 0, microsecond=0)
|
||||
endTime = startTime + datetime.timedelta(hours=24)
|
||||
now = startTime.isoformat() + 'Z'
|
||||
end = endTime.isoformat() + 'Z'
|
||||
print('Looking for events between', now, end)
|
||||
events_result = self.service.events().list(calendarId=calid, timeMin=now,
|
||||
timeMax=end, maxResults=10, singleEvents=True,
|
||||
orderBy='startTime').execute()
|
||||
events = events_result.get('items', [])
|
||||
return events
|
||||
return events_result.get('items', [])
|
||||
|
||||
def help(self):
|
||||
return('Google calendar. Lists 10 next events by default. today = list today\'s events.')
|
||||
|
|
Loading…
Reference in New Issue