-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code cleanup, split into multiple files
Signed-off-by: Matthias <[email protected]>
- Loading branch information
1 parent
8d78a0e
commit 0156753
Showing
37 changed files
with
821 additions
and
749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,27 +14,33 @@ Clone this repo with submodules: `git clone --recurse-submodules [email protected]: | |
|
||
On linux run setup.sh to get you started with all requirements for a python environment. | ||
|
||
First you should insert your secrets into the file `configs/private/secrets/weeklysecrets.yaml`. | ||
First you should insert your secrets into the file `configs/private/secrets/weekly.yaml`. | ||
You would need to create that file looking something like this: | ||
|
||
``` | ||
runnable: False | ||
mail_user: "somegmailusername" | ||
mail_pw: "somegmailssecretpasswort" | ||
bluesky_TOKEN: "x3xx-xyz-xyz-abcd" | ||
bluesky_USER: "[email protected]" | ||
forum_KEY: "abcdef123456" | ||
mastondon_INSTANCE: "yourinstance.social" | ||
josm_PW: "yourJosmWikiPass" | ||
josm_USER: "yourJosmWikiUser" | ||
mail_PW: "somegmailssecretpasswort" | ||
mail_USER: "somegmailusername" | ||
mastodon_INSTANCE: "yourinstance.social" | ||
mastodon_TOKEN: "yourMastodonDeveloperApplicationAccessToken" | ||
matrix_USER: "@youruser:matrix.org" | ||
matrix_BASE: "https://matrix.org" | ||
matrix_TOKEN: "syt_tokentoken_tokentoken_token" | ||
tw_CONSUMER_KEY: "yourTwitterConsumerKey" | ||
tw_CONSUMER_SECRET: "yourTwitterConsumerSecretFrdsfor09512kljda98324iu21as" | ||
matrix_USER: "@youruser:matrix.org" | ||
telegram_TOKEN: "YourTelegramBotToken123:456" | ||
tw_ACCESS_KEY: "123456-YourTWAccessKeyNelsonMandela4Evaaaa" | ||
tw_ACCESS_SECRET: "YourTWAccessSecretlsdkhjkahdkjahsrwqkjhqwkjhewqkjewqh" | ||
telegram_TOKEN: "YourTelegramBotToken123:456" | ||
josm_user: "yourJosmWikiUser" | ||
jsom_pw: "yourJosmWikiPass" | ||
``` | ||
tw_BEARER_TOKEN: "AAAAAAAAAAabcdefg" | ||
tw_CLIENT_ID: "abcdef123456xyz" | ||
tw_CLIENT_SECRET: "123456abcdef789" | ||
tw_CONSUMER_KEY: "0123456consumerkeyABC" | ||
tw_CONSUMER_KEY: "yourTwitterConsumerKey" | ||
tw_CONSUMER_SECRET: "yourTwitterConsumerSecretFrdsfor09512kljda98324iu21as" | ||
``` | ||
|
||
Next you should define the recipients for each language in a `weekly_*.yaml` as defined in your `configs/configs.yaml` | ||
|
||
|
@@ -78,10 +84,10 @@ It takes the same parameters as the python script but fixes PYTHONIOENCODING to | |
|
||
test call - for twitter | ||
``` | ||
./runenvweekly2all.sh --twitter --pic ~/downloads/C3wrVxcWcAEhtrU.jpg --showpic "WEEKLYTWTEST" "en,de,fr" | ||
./runenvweekly2all.sh --twitter --pic ~/downloads/abc.jpg --showpic "WEEKLYTEST" "en" | ||
``` | ||
|
||
how to call - mail, forum, josm, telegram, mastodon and twitter | ||
how weeklyOSM is announced: | ||
``` | ||
./runenvweekly2all.sh --bluesky --forum --josm --mail --mastodon --matrix --telegram --pic auto --showpic "WEEKLY" "int,de,en,es,pt,tr,ru,ja,fr,it,ko,br,zh,pl,uk" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ do_mail: True # " wenn dieses auskommentiert wird, wird der paramterer "--mail" | |
do_twitter: False #" wenn dieses auskommentiert wird, wird der paramterer "--twitter" ignoriert und NICHT getwittert | ||
do_mastodon: False #" wenn dieses auskommentiert wird, wird der paramterer "--mastodon" ignoriert und NICHT getootet | ||
do_forum: False | ||
mail_from: "weeklyteam <{c.mail_user}>" | ||
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 configs/private/mailto/ folder | ||
|
Submodule private
updated
from 199288 to abbf02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import re | ||
|
||
from atproto import ( | ||
Client as blueskyclient, | ||
models as bluesky_models, | ||
) | ||
|
||
|
||
def post(self): | ||
self.logger.info(f"...posting on bluesky...") | ||
|
||
# log in to bluesky.social | ||
try: | ||
client = blueskyclient() | ||
client.login(self.bluesky_USER, self.bluesky_TOKEN) | ||
except Exception as e: | ||
self.logger.error("cannot log in to bluesky.") | ||
self.logger.error(e) | ||
return False | ||
|
||
# load picture | ||
try: | ||
if self.pic: | ||
self.logger.debug("sending post with image") | ||
with open(self.pic, "rb") as f: | ||
media = f.read() | ||
except Exception as e: | ||
self.logger.error("cannot read picture") | ||
self.logger.error(e) | ||
return False | ||
|
||
# detect any links beginning with http to make them clickable | ||
try: | ||
pattern = rb"https?://[^ \n\r\t]*" | ||
matches = re.finditer(pattern, self.bluesky_text.encode("UTF-8")) | ||
url_positions = [] | ||
for match in matches: | ||
url_bytes = match.group(0) | ||
url = url_bytes.decode("UTF-8") | ||
url_positions.append((url, match.start(), match.end())) | ||
facets = [] | ||
for link_data in url_positions: | ||
uri, byte_start, byte_end = link_data | ||
facets.append( | ||
bluesky_models.AppBskyRichtextFacet.Main( | ||
features=[bluesky_models.AppBskyRichtextFacet.Link(uri=uri)], | ||
index=bluesky_models.AppBskyRichtextFacet.ByteSlice( | ||
byte_start=byte_start, byte_end=byte_end | ||
), | ||
) | ||
) | ||
except Exception as e: | ||
self.logger.warning("error detecting links, cannot make them clickable") | ||
self.logger.error(e) | ||
facets = [] | ||
|
||
# send post | ||
try: | ||
if self.pic: | ||
client.send_image( | ||
text=self.bluesky_text, | ||
image=media, | ||
image_alt="weeklyOSM title image", | ||
facets=facets, | ||
) | ||
else: | ||
client.send_post(self.bluesky_text, facets=facets) | ||
except Exception as e: | ||
self.logger.error("could not post to bluesky") | ||
self.logger.error(e) | ||
return False |
Oops, something went wrong.