mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
fix querying and hlpers
This commit is contained in:
parent
59ece469a5
commit
a83f2f1d30
2 changed files with 10 additions and 9 deletions
|
@ -72,13 +72,17 @@ def create_accounts():
|
||||||
@app.cli.command("post_new_memes")
|
@app.cli.command("post_new_memes")
|
||||||
def post_new_memes():
|
def post_new_memes():
|
||||||
# run every 5 mins
|
# 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:
|
for post in all_posts:
|
||||||
diff = datetime.now() - post.timestamp
|
diff = datetime.now() - post.timestamp
|
||||||
recent_post = diff < timedelta(hours=2)
|
recent_post = diff < timedelta(hours=2)
|
||||||
if recent_post:
|
if recent_post:
|
||||||
make_post(post)
|
if not post.to_reddit:
|
||||||
post_discord_webhook(post)
|
make_post(post)
|
||||||
|
if not post.to_discord:
|
||||||
|
post_discord_webhook(post)
|
||||||
return
|
return
|
||||||
|
|
||||||
@app.cli.command("reddit_random")
|
@app.cli.command("reddit_random")
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
|
from random import choice
|
||||||
from suchwow import config
|
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"]
|
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
|
discord_webhook_url = config.DISCORD_URL
|
||||||
r = requests.post(discord_webhook_url, data=msg)
|
r = requests.post(discord_webhook_url, data=msg)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
if r.status.ok:
|
print(f"Posted #{post.id} to Discord")
|
||||||
print(f"Posted #{post.id} to Discord")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print(f"Unable to post #{post.id} to Discord")
|
|
||||||
return False
|
|
||||||
|
|
Loading…
Reference in a new issue