Dump everything

master
chadbsduser 1 year ago
commit 363d8d39ac

@ -0,0 +1,5 @@
Copyright © 2023 by niggasinparis <imevil@cock.li>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

@ -0,0 +1,14 @@
'id' contains an integer specifying the id (suchwow) of the last meme posted to reddit
Steps:
Go to https://www.reddit.com/prefs/apps
Click "Create App" and select "script"
Enter any valid url as the redirect url
Enter any name in the name field ('Wowbot' preferred)
Copy the app key (below name) and replace <oauth key> with the key
Copy the app secret and replace <oauth secret> with the secret
Replace <username> and <password> with your bot's credentials
Workaround for spam filter:
Add your bot to your subreddit as a mod with perms to manage posts
Set mod=1 in the code

1
id

@ -0,0 +1 @@
6000

@ -0,0 +1,118 @@
import requests, json
from time import sleep
mod = 1
headers = {'User-Agent': 'Wowbot/1.0.0'}
key = '<oauth key>'
secret = '<oauth secret>'
account = {"username": '<username>', "password": '<password>'}
token = 'dummy'
headers["Authorization"] = f'bearer {token}'
def get_oauth(key, secret, account):
creds = {"grant_type": 'password', **account}
auth = requests.auth.HTTPBasicAuth(key, secret)
request = {"auth": auth, "data": creds, "headers": headers}
response = requests.post('https://www.reddit.com/api/v1/access_token', **request)
return response.json()["access_token"]
def suchwow_list():
return requests.get("https://suchwow.xyz/api/list").json()
def fix_token():
global token, headers
token = get_oauth(key, secret, account)
headers["Authorization"] = f'bearer {token}'
def reddit_post(title, url):
data = {"api_type": 'json', "kind": 'image', "url": url, "title": title, "sr": 'bottest200000'}
request = {"headers": headers, "data": data}
response = requests.post('https://oauth.reddit.com/api/submit', **request)
if (response.status_code == 401):
fix_token()
return reddit_post(title, url)
elif (response.status_code == 200):
return response.json()
def reddit_reply(fullname, text):
data = {"api_type": 'json', "text": text, "thing_id": fullname}
request = {"headers": headers, "data": data}
response = requests.post('https://oauth.reddit.com/api/comment', **request)
if (response.status_code == 401):
fix_token()
return reddit_reply(fullname, text)
elif (response.status_code == 200):
return response.json()
def reddit_approve(id):
data = {"id": id}
request = {"headers": headers, "data": data}
response = requests.post('https://oauth.reddit.com/api/approve', **request)
if (response.status_code == 401):
fix_token()
return reddit_reply(fullname, text)
elif (response.status_code == 200):
return response
while True:
# bool for new posts
new = 0
f = open("id","r+")
id = f.readline().strip("\n")
list = suchwow_list()
for n, post in enumerate(list, start = 1):
if (post["id"] <= int(id)):
break
else:
new = 1
last = n
print(post["id"])
if (new == 1):
max = list[0]["id"]
print(max)
list = list[:last]
list.reverse()
for post in list:
title = f'SuchWow #{post["id"]} - '
topiclen = 300 - len(title)
if (len(post["title"]) > topiclen):
topiclen = topiclen - 3
topic = f'{post["title"][:topiclen]}...'
else:
topic = post["title"]
title = f'{title}{topic}'
rpost = reddit_post(title, post["image"])
rpostname = rpost["json"]["data"]["name"]
text = f'Submitted by {post["submitter"]}\n\nTimestamp: {post["timestamp"]}\n\n#[View Post]({post["href"]})\n'
reply = reddit_reply(rpostname, text)
replyname = reply["json"]["data"]["things"][0]["data"]["name"]
if (mod == 1):
print(f"Approving {rpostname}, {replyname}\n")
sleep(10)
resp = reddit_approve(rpostname)
reddit_approve(replyname)
id = post["id"]
f.truncate(0)
f.seek(0)
f.write(f'{id}\n')
if (id < max):
print("Waiting...\n")
sleep(3)
f.close()
sleep(120)
Loading…
Cancel
Save