mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
yoloing a discord webhook
This commit is contained in:
parent
998fdb730c
commit
7d7caf803d
3 changed files with 28 additions and 3 deletions
|
@ -10,6 +10,7 @@ from suchwow.models import Post, Profile, Comment, Notification, db
|
|||
from suchwow.routes import auth, comment, post, profile, leaderboard
|
||||
from suchwow.utils.decorators import login_required
|
||||
from suchwow.reddit import make_post
|
||||
from suchwow.discord import post_discord_webhook
|
||||
from suchwow import wownero
|
||||
|
||||
|
||||
|
@ -68,8 +69,8 @@ def create_accounts():
|
|||
account = wallet.new_account()
|
||||
print(f"Created account {account}")
|
||||
|
||||
@app.cli.command("reddit_recent")
|
||||
def reddit_recent():
|
||||
@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)
|
||||
for post in all_posts:
|
||||
|
@ -77,6 +78,7 @@ def reddit_recent():
|
|||
recent_post = diff < timedelta(hours=2)
|
||||
if recent_post:
|
||||
make_post(post)
|
||||
post_discord_webhook(post)
|
||||
return
|
||||
|
||||
@app.cli.command("reddit_random")
|
||||
|
|
|
@ -17,4 +17,5 @@ PRAW_CLIENT_ID = 'xxxxxxxx'
|
|||
PRAW_USER_AGENT = 'suchwow-yyyy-python'
|
||||
PRAW_USERNAME = 'xxxxxxxx'
|
||||
PRAW_PASSWORD = 'xxxxxxxx'
|
||||
SERVER_NAME = 'suchwow.xyz'
|
||||
SERVER_NAME = 'localhost'
|
||||
DISCORD_URL = 'xxxxxxx'
|
||||
|
|
22
suchwow/discord.py
Normal file
22
suchwow/discord.py
Normal 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
|
Loading…
Reference in a new issue