Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- import re
- import sqlite3
- reddit = praw.Reddit(
- username='earthpornbot2',
- password='',
- client_id='',
- client_secret='',
- user_agent='verfied email checker v1 by inqw',
- api_request_delay=0)
- def connect_database():
- file = re.sub('\.\w+$','.db',__file__)
- conn = sqlite3.connect(file)
- return conn
- def create_database():
- file = open(re.sub('\.\w+$','.sql',__file__))
- db = connect_database()
- db.cursor().executescript(file.read())
- class Profile:
- def __init__(self, submission):
- self.submission = submission
- self.author = submission.author
- self.url = submission.url
- self.permalink = submission.permalink
- self.id = submission.id
- self.conn = connect_database()
- self.cur = self.conn.cursor()
- self.__call__()
- @property
- def hasRemoved(self):
- content = self.cur.execute('select * from removed where submission_id=?',(self.id,)).fetchone()
- if not content:
- return False
- else:
- return True
- @property
- def hasEmail(self):
- trophies_url = '/api/v1/user/{}/trophies'
- user = reddit.request('GET',trophies_url.format(self.author.name))['data']['trophies']
- trophies = [thing['name'] for thing in [trophy['data'] for trophy in user]]
- if 'Verified Email' in trophies:
- return True
- else:
- return False
- @property
- def youngAccount(self):
- min_age_req = 90
- current_time = time.time()
- created_time = self.author.created_utc
- difference = current_time - created_time
- account_age = difference // (60 * 60 * 24)
- if account_age < min_age_req:
- return True
- else:
- return False
- def addEntry(self):
- self.cur.execute('insert into removed values(?,?,?)',(self.author.name, self.permalink, self.id,))
- self.cur.execute('insert into authors values(?)',(self.author.name,))
- self.conn.commit()
- def __call__(self):
- try:
- if (self.youngAccount and not self.hasEmail) and not self.hasRemoved:
- self.addEntry()
- self.submission.mod.remove()
- return True
- else:
- return False
- except:
- return False
- def accept_invites(inbox):
- for message in inbox:
- if 'invitation to moderate' in message.subject:
- try:
- message.subreddit.mod.accept_invite()
- message.mark_read()
- except:
- pass
- def main():
- for submission in reddit.subreddit('earthporn').stream.submissions():
- post = Profile(submission)
- if post == True:
- print("Removed submission by /u/{}".format(submission.author.name))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement