fix querying and hlpers

graphs-n-shit
lza_menace 4 years ago
parent 59ece469a5
commit a83f2f1d30

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

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

Loading…
Cancel
Save