Skip to content

Commit

Permalink
Improve posting to Twitter and BlueSky platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
dachosen1 committed Dec 22, 2024
1 parent 99b9fc1 commit 0e2e3e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
post_type="fact",
message=message,
)
post_to_all_platforms(tweet_text=tweet_text.get("post"))
post_to_all_platforms(text=tweet_text.get("post"))
save_tweet_to_db(tweet_text, conn)

if args.weekly:
Expand All @@ -124,7 +124,7 @@
post_type="fact",
message=message,
)
post_to_all_platforms(tweet_text=tweet_text.get("post"))
post_to_all_platforms(text=tweet_text.get("post"))
save_tweet_to_db(tweet_text, conn)

if args.monthly:
Expand All @@ -149,7 +149,7 @@
post_type="fact",
message=message,
)
post_to_all_platforms(tweet_text=tweet_text.get("post"))
post_to_all_platforms(text=tweet_text.get("post"))
save_tweet_to_db(tweet_text, conn)

if args.initialize:
Expand All @@ -161,7 +161,7 @@

tweet_text = format_earthquake_alert(post_type="fact", message=message)

post_to_all_platforms(tweet_text=tweet_text.get("post"))
post_to_all_platforms(text=tweet_text.get("post"))
save_tweet_to_db(tweet_text, conn)

if args.backfill:
Expand Down
5 changes: 3 additions & 2 deletions nearquake/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
generate_coordinate_lookup_detail_url,
generate_time_range_url,
)
from nearquake.post_manager import post_to_all_platforms
from nearquake.post_manager import post_to_all_platforms, save_tweet_to_db
from nearquake.utils import (
convert_timestamp_to_utc,
fetch_json_data_from_url,
Expand Down Expand Up @@ -319,7 +319,8 @@ def upload(self):
)

try:
post_to_all_platforms(post_text=tweet_text)
post_to_all_platforms(text=tweet_text.get("post"))
save_tweet_to_db(tweet_text, self.conn)

except Exception as e:
_logger.error(
Expand Down
4 changes: 2 additions & 2 deletions nearquake/post_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def save_tweet_to_db(tweet_text: dict, conn) -> bool:
return False


def post_to_all_platforms(post_text: str) -> dict:
def post_to_all_platforms(text: str) -> dict:
platforms = [TwitterPost(), BlueSkyPost()]
for platform in platforms:
platform.post(post_text)
platform.post(text)

0 comments on commit 0e2e3e4

Please sign in to comment.