From a83f2f1d30478a2238e3cef16e7536c34115bec3 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 29 Oct 2020 01:24:55 -0700 Subject: [PATCH] fix querying and hlpers --- suchwow/app.py | 10 +++++++--- suchwow/discord.py | 9 +++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index a25d262..d6be722 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -72,13 +72,17 @@ def create_accounts(): @app.cli.command("post_new_memes") def post_new_memes(): # run every 5 mins - all_posts = Post.select().order_by(Post.timestamp.desc()).where(Post.to_reddit == False, Post.to_discord == False) + all_posts = Post.select().order_by(Post.timestamp.desc()).where( + (Post.to_reddit == False) | (Post.to_discord == False) + ) for post in all_posts: diff = datetime.now() - post.timestamp recent_post = diff < timedelta(hours=2) if recent_post: - make_post(post) - post_discord_webhook(post) + if not post.to_reddit: + make_post(post) + if not post.to_discord: + post_discord_webhook(post) return @app.cli.command("reddit_random") diff --git a/suchwow/discord.py b/suchwow/discord.py index 953c11c..ba5be06 100644 --- a/suchwow/discord.py +++ b/suchwow/discord.py @@ -1,5 +1,7 @@ import requests +from random import choice from suchwow import config +from suchwow import wownero intro = ["Whatup", "What is up", "What the fuck is up", "what in the fuck is up", "Yo"] @@ -14,9 +16,4 @@ def post_discord_webhook(post): discord_webhook_url = config.DISCORD_URL r = requests.post(discord_webhook_url, data=msg) r.raise_for_status() - if r.status.ok: - print(f"Posted #{post.id} to Discord") - return True - else: - print(f"Unable to post #{post.id} to Discord") - return False + print(f"Posted #{post.id} to Discord")