disable mail option
This commit is contained in:
parent
bd655cb883
commit
5818ac080a
13
README.md
13
README.md
@ -4,11 +4,20 @@ This python script fetches the latest tweet of a public user from twitter and ou
|
|||||||
directory. This script expects two json files in `/etc/tw2hugo`, which should have `chmod 700` for a non-privileged
|
directory. This script expects two json files in `/etc/tw2hugo`, which should have `chmod 700` for a non-privileged
|
||||||
user and no rights for the group. All files should have `chmod 400`.
|
user and no rights for the group. All files should have `chmod 400`.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
This package depends only on the pip package "requests", which I recommend to simply install globally with
|
||||||
|
`pip3 install requests`. You can also use the provided pipfile and install all dependencies into a virtual environment
|
||||||
|
with `pipenv lock`, however, you will need to activate that environment in your automation script.
|
||||||
|
|
||||||
|
Next, you will need to install the configuration files below:
|
||||||
|
|
||||||
## Needed configuration files
|
## Needed configuration files
|
||||||
|
|
||||||
/etc/tw2hugo/mail_credentials.json
|
/etc/tw2hugo/mail_credentials.json
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
|
"enable": true,
|
||||||
"smtp-server": "mail server",
|
"smtp-server": "mail server",
|
||||||
"smtp-port": 465,
|
"smtp-port": 465,
|
||||||
"email-user": "username for smtp",
|
"email-user": "username for smtp",
|
||||||
@ -23,14 +32,14 @@ user and no rights for the group. All files should have `chmod 400`.
|
|||||||
{
|
{
|
||||||
"bearer": "bearer token of your twitter app",
|
"bearer": "bearer token of your twitter app",
|
||||||
"twitter-handle": "twitter handle",
|
"twitter-handle": "twitter handle",
|
||||||
"output-location": "hugo base dir/data/latest_tweet.json"
|
"output-location": "/hugo/project/directory/data/latest_tweet.json"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Why does it need email credentials?
|
## Why does it need email credentials?
|
||||||
|
|
||||||
The script has the specialty that sends an email when something goes wrong, so I am notifed and can fix the issue.
|
The script has the specialty that sends an email when something goes wrong, so I am notifed and can fix the issue.
|
||||||
If you don't want that, simply open `mail/mail.py` and replace everyting in the init function with a simple `pass`.
|
If you don't want that, replace `enable: true` in the `mail_credentials.json` with `false`.
|
||||||
|
|
||||||
## How does it integrate into Hugo?
|
## How does it integrate into Hugo?
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"enable": true,
|
||||||
"smtp-server": "smtp.example.com",
|
"smtp-server": "smtp.example.com",
|
||||||
"smtp-port": 465,
|
"smtp-port": 465,
|
||||||
"email-user": "notify@example.com",
|
"email-user": "notify@example.com",
|
||||||
|
@ -26,6 +26,9 @@ class mail:
|
|||||||
with path.open("r") as fp:
|
with path.open("r") as fp:
|
||||||
credentials = j_load(fp)
|
credentials = j_load(fp)
|
||||||
|
|
||||||
|
if not credentials['enable']:
|
||||||
|
return
|
||||||
|
|
||||||
message = MIMEText(what, _charset='utf8')
|
message = MIMEText(what, _charset='utf8')
|
||||||
message['Subject'] = "Tweet2Hugo alarm report"
|
message['Subject'] = "Tweet2Hugo alarm report"
|
||||||
message['From'] = credentials['email-sendfrom']
|
message['From'] = credentials['email-sendfrom']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user