fix querying and hlpers

This commit is contained in:
lza_menace 2020-10-29 01:24:55 -07:00
parent 59ece469a5
commit a83f2f1d30
2 changed files with 10 additions and 9 deletions

View file

@ -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")

View file

@ -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")