Fixed dockerfile, always setup googlecal files.
This commit is contained in:
parent
50ada1d6d7
commit
e1c444024f
12
Dockerfile
12
Dockerfile
|
@ -3,14 +3,16 @@ FROM python:3
|
||||||
WORKDIR /bot
|
WORKDIR /bot
|
||||||
RUN pip install pipenv
|
RUN pip install pipenv
|
||||||
COPY Pipfile .
|
COPY Pipfile .
|
||||||
RUN pipenv install --pre --system
|
RUN pipenv install --pre
|
||||||
|
|
||||||
COPY bot.py .
|
COPY bot.py .
|
||||||
COPY modules modules
|
COPY modules modules
|
||||||
|
|
||||||
# Uncomment for google calendar:
|
# Make sure these exist
|
||||||
|
RUN touch credentials.json
|
||||||
|
RUN touch token.pickle
|
||||||
|
|
||||||
#COPY credentials.json .
|
COPY credentials.json .
|
||||||
#COPY token.pickle .
|
COPY token.pickle .
|
||||||
|
|
||||||
CMD [ "python", "-u", "./bot.py" ]
|
CMD [ "pipenv", "run", "python", "-u", "./bot.py" ]
|
||||||
|
|
|
@ -63,14 +63,15 @@ To set up, you'll need to generate oauth2 credentials.json file - see https://co
|
||||||
Run the bot on *local* machine as OAuth2 wants to open localhost url in your browser. I haven't found out an easy way to
|
Run the bot on *local* machine as OAuth2 wants to open localhost url in your browser. I haven't found out an easy way to
|
||||||
do this on server.
|
do this on server.
|
||||||
|
|
||||||
When credentials.json is present, you must authenticate the bot to access calendar. There will be a link in console like this:
|
There is a empty credentials.json file in the bot directory. Replace it with yours. When credentials.json is present, you must
|
||||||
|
authenticate the bot to access calendar. There will be a link in console like this:
|
||||||
|
|
||||||
``` text
|
``` text
|
||||||
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=907....
|
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=907....
|
||||||
```
|
```
|
||||||
|
|
||||||
Open the link and authenticate as needed. A new file token.pickle will be created in the directory and bot will read it in future.
|
Open the link and authenticate as needed. A new file token.pickle will be created in the directory and bot will read it in future.
|
||||||
Save the token.pickle and ship it with the bot to your server. Edit Dockerfile to copy it in container if needed.
|
Save the token.pickle and ship it with the bot to your server.
|
||||||
|
|
||||||
Now the bot should be usable.
|
Now the bot should be usable.
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class MatrixModule:
|
||||||
|
|
||||||
creds = None
|
creds = None
|
||||||
|
|
||||||
if not os.path.exists(self.credentials_file):
|
if not os.path.exists(self.credentials_file) or os.path.getsize(self.credentials_file) == 0:
|
||||||
return # No-op if not set up
|
return # No-op if not set up
|
||||||
|
|
||||||
if os.path.exists('token.pickle'):
|
if os.path.exists('token.pickle'):
|
||||||
|
|
Loading…
Reference in New Issue