yoloing a discord webhook

This commit is contained in:
lza_menace 2020-10-29 00:57:08 -07:00
parent 998fdb730c
commit 7d7caf803d
3 changed files with 28 additions and 3 deletions

View file

@ -10,6 +10,7 @@ from suchwow.models import Post, Profile, Comment, Notification, db
from suchwow.routes import auth, comment, post, profile, leaderboard from suchwow.routes import auth, comment, post, profile, leaderboard
from suchwow.utils.decorators import login_required from suchwow.utils.decorators import login_required
from suchwow.reddit import make_post from suchwow.reddit import make_post
from suchwow.discord import post_discord_webhook
from suchwow import wownero from suchwow import wownero
@ -68,8 +69,8 @@ def create_accounts():
account = wallet.new_account() account = wallet.new_account()
print(f"Created account {account}") print(f"Created account {account}")
@app.cli.command("reddit_recent") @app.cli.command("post_new_memes")
def reddit_recent(): 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) all_posts = Post.select().order_by(Post.timestamp.desc()).where(Post.to_reddit == False)
for post in all_posts: for post in all_posts:
@ -77,6 +78,7 @@ def reddit_recent():
recent_post = diff < timedelta(hours=2) recent_post = diff < timedelta(hours=2)
if recent_post: if recent_post:
make_post(post) make_post(post)
post_discord_webhook(post)
return return
@app.cli.command("reddit_random") @app.cli.command("reddit_random")

View file

@ -17,4 +17,5 @@ PRAW_CLIENT_ID = 'xxxxxxxx'
PRAW_USER_AGENT = 'suchwow-yyyy-python' PRAW_USER_AGENT = 'suchwow-yyyy-python'
PRAW_USERNAME = 'xxxxxxxx' PRAW_USERNAME = 'xxxxxxxx'
PRAW_PASSWORD = 'xxxxxxxx' PRAW_PASSWORD = 'xxxxxxxx'
SERVER_NAME = 'suchwow.xyz' SERVER_NAME = 'localhost'
DISCORD_URL = 'xxxxxxx'

22
suchwow/discord.py Normal file
View file

@ -0,0 +1,22 @@
import requests
from suchwow import config
intro = ["Whatup", "What is up", "What the fuck is up", "what in the fuck is up", "Yo"]
insults = ["fart sacks", "dick lips", "shit stains", "chodes", "cum guzzlers", "dipshits", "dicknipples", "turd burglars"]
def post_discord_webhook(post):
wallet = wownero.Wallet()
post_wow_address = wallet.get_address(account=post.account_index)
content = f"{choice(intro)} {choice(insults)}, check out the new SuchWow post #{post.id} from {post.submitter}! Send funds to [{post_wow_address}](https://wownero.club/address/{post_wow_address}) to show support!"
msg = {"content": content}
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