Skip to content

Commit

Permalink
add secrets as submodule, update readme
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias <matthias@peanut>
  • Loading branch information
Matthias authored and Matthias committed Feb 19, 2023
1 parent e9e08d0 commit 94b3f15
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ docs/_build/
# PyBuilder
target/

configs/secrets/
# secrets and personal data:
configs/private/

spamenv/
.vscode/tags

configs/mailto/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "configs/private"]
path = configs/private
url = [email protected]:call-me-matt/weeklyOSMnotifier-secrets.git
60 changes: 33 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@


# weeklyOSM "SPAM" Tool
This is the OSM Weekly "SPAM" Tool for sending updates in different languages. It supports posting to a forum,
sending emails via google and sending toots via mastodon and twitter.
Feel free to use it as a baseline for simmilar usecases.
# weeklyOSM Notification Tool
This is the OSM Weekly Notification Tool for sending updates in different languages. It supports posting to a forum,
sending emails and toots and tweets. Feel free to use it as a baseline for simmilar usecases.


> Disclaimer:
> This script is _completely_ unsupported! It comes "as is" besides from request surrounding weeklyosm your issue-tickets or pull-requests will most likely be ignored.
> This software is unlicensed! For more information, please refer to <http://unlicense.org>
## installation

Clone this repo with submodules: `git clone --recurse-submodules [email protected]:call-me-matt/weeklyOSMnotifier.git`

On linux run setup.sh to get you started with all requirements for a python environment.

You should first edit configs/configs.yaml to your needs.
Note that by default all weekly_*.yaml files inherit their secrets from the file configs/secrets/weeklysecrets.yaml.
First you should insert your secrets into the file `configs/private/secrets/weeklysecrets.yaml`.
You would need to create that file looking something like this:

```
runnable: False
mail_user: 'somegmailusername'
mail_pw: somegmailssecretpasswort
mail_user: "somegmailusername"
mail_pw: "somegmailssecretpasswort"
forum_KEY: "abcdef123456"
mastondon_INSTANCE: "yourinstance.social"
mastodon_TOKEN: "yourMastodonDeveloperApplicationAccessToken"
tw_CONSUMER_KEY: "yourTwitterConsumerKey"
Expand All @@ -29,10 +31,7 @@ tw_ACCESS_SECRET: "YourTWAccessSecretlsdkhjkahdkjahsrwqkjhqwkjhewqkjewqh"
telegram_TOKEN: "YourTelegramBotToken123:456"
```

Note that you have to enable sending e-mails via that account in your google-mail-account settings.

You can override the mail distribution lists with some private mail adress.
I.E. configs/mailto/weekly.pb could be created with the following content:
Next you should define the recipients for each language in a `weekly_*.yaml` as defined in your `configs/configs.yaml`

```
mail_to:
Expand All @@ -41,13 +40,30 @@ mail_to:
- "[email protected]"
- "[email protected]"
- "[email protected]"
forum_to: "123456" # posts into https://community.openstreetmap.org/t/some-title/123456/
# only one thread possible per language due to forum's antispam
telegram_to: # send telegram messages to the following recipients (if group, bot must be admin)
- -123456789 # groups have negative identifiers
- -987654321
```
## Adding a new language xx

That would replace the mail_to: property from the file config/weekly_pb.yaml
leading to additional mail sent to the first three lines instead of only to the brasilian osm-lists.
1. in your `configs.yaml` add two lines for the xx language
```
- weekly_xx.yaml:
- private/mailto/weekly_xx.yaml
```
2. create `weekly_xx.yaml` in the `configs`-folder. content: text bodies of notifications in xx
3. in your `configs/private/mailto`-folder, create `weekly_xx.yaml`. content: notification recipients for xx

If you copy from another language, don't forget to change the language_header

## Utilization

For calling this from a script within the prepared environment call the shellscript runenvweekly2all.sh.
For calling this from a script within the prepared environment call the shellscript `runenvweekly2all.sh`.
It takes the same parameters as the python script but fixes PYTHONIOENCODING to UTF-8 and LC_CTYPE to C.UFT-8 avoiding issues when called from node or other environments.


Expand All @@ -56,17 +72,7 @@ test call - for twitter
./runenvweekly2all.sh --twitter --pic ~/downloads/C3wrVxcWcAEhtrU.jpg --showpic "WEEKLYTWTEST" "en,de,fr" "401" "7831" "23.02.2016" "29.02.2016"
```

how to call - mail, mastodon and twitter
how to call - mail, forum, telegram, mastodon and twitter
```
./runenvweekly2all.sh --mail --forum --telegram --mastodon --twitter --pic ~/Downloads/420_T_EN.jpg --showpic "WEEKLY" "int,en,ja,ko,zh,cn,id,ru,tr,uk,pl,it,pt,es,fr,de" "420" "10586" "2018-07-31" "2018-08-06"
```

INTRODUCING a new language xx
1. in configs.yaml add two lines for the xx language
- weekly_xx.yaml:
- mailto/weekly_xx.yaml
2. in mailto
- create weekly_xx.yaml - content: email addresses
3. create weekly_xx.yaml - content: mastodon, twitter and email text

If you copy from another language ... DON'T forget to change the language_header
42 changes: 21 additions & 21 deletions configs/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@
# Each config which is loaded passes its settings down to files which are loaded as children
# Children as such can override settings from their parents
# Each config which leaves its "runnable" flag set to True
# Will be added by context and language to the list of available configurations
# Will be added by context and language to the list of available configurations
# Note that if you don't provide a new context or language key in a file
# the child might overwrite any other existing configuration with the same context name and language
# - in some cases this might be wanted behaviour - like keeping e-mail adresses secret

- secrets/weeklysecrets.yaml:
- private/secrets/weeklysecrets.yaml:
- weekly_base.yaml:
- weekly_int.yaml:
- mailto/weekly_int.yaml
- private/mailto/weekly_int.yaml
- weekly_en.yaml:
- mailto/weekly_en.yaml
- private/mailto/weekly_en.yaml
- weekly_de.yaml:
- mailto/weekly_de.yaml
- private/mailto/weekly_de.yaml
- weekly_es.yaml:
- mailto/weekly_es.yaml
- private/mailto/weekly_es.yaml
- weekly_pt.yaml:
- mailto/weekly_pt.yaml
- private/mailto/weekly_pt.yaml
- weekly_fr.yaml:
- mailto/weekly_fr.yaml
- private/mailto/weekly_fr.yaml
- weekly_sw.yaml:
- mailto/weekly_sw.yaml
- private/mailto/weekly_sw.yaml
- weekly_ko.yaml:
- mailto/weekly_ko.yaml
- private/mailto/weekly_ko.yaml
- weekly_id.yaml:
- mailto/weekly_id.yaml
- private/mailto/weekly_id.yaml
- weekly_it.yaml:
- mailto/weekly_it.yaml
- private/mailto/weekly_it.yaml
- weekly_pl.yaml:
- mailto/weekly_pl.yaml
- private/mailto/weekly_pl.yaml
- weekly_zh.yaml:
- mailto/weekly_zh.yaml
- private/mailto/weekly_zh.yaml
- weekly_cn.yaml:
- mailto/weekly_cn.yaml
- private/mailto/weekly_cn.yaml
- weekly_ru.yaml:
- mailto/weekly_ru.yaml
- private/mailto/weekly_ru.yaml
- weekly_tr.yaml:
- mailto/weekly_tr.yaml
- private/mailto/weekly_tr.yaml
- weekly_ja.yaml:
- mailto/weekly_ja.yaml
- private/mailto/weekly_ja.yaml
- weekly_uk.yaml:
- mailto/weekly_uk.yaml
- private/mailto/weekly_uk.yaml
- emailtest.yaml:
- mailto/emailtest.yaml
- secrets/weeklytwtest_secrets.yaml:
- private/mailto/emailtest.yaml
- private/secrets/weeklytwtest_secrets.yaml:
- weeklytwtest_en.yaml
2 changes: 1 addition & 1 deletion configs/emailtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ do_forum: False
mail_from: "weeklyteam <{c.mail_user}>"
mail_subject: 'Python email test'
mail_to:
- "[email protected]" # this property gets overwritten in the file with the same name found in mailto/ folder
- "[email protected]" # this property gets overwritten in the file with the same name found in configs/private/mailto/ folder
mail_body: |
This is test...
This is _only_ a test!
Expand Down
1 change: 1 addition & 0 deletions configs/private
Submodule private added at 03b688
2 changes: 1 addition & 1 deletion get_telegram_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import telepot
import yaml

with open('configs/secrets/weeklysecrets.yaml') as f:
with open('configs/private/secrets/weeklysecrets.yaml') as f:
# use safe_load instead load
secrets = yaml.safe_load(f)

Expand Down

0 comments on commit 94b3f15

Please sign in to comment.