Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import discord
  2. import asyncio
  3. import praw
  4. import time
  5. from discord.ext import commands
  6.  
  7. reddit = praw.Reddit(client_id='dJCf1KddZkYxGA',
  8. client_secret='6O7rBxqGDMnrkwXfDuLpeLsPRqI',
  9. user_agent='pc:com.example.reddittronforprivate:v1.0.0 (by /u/yukineismybae)',
  10. username='yukineismybae',
  11. password='Pokemon999')
  12.  
  13. client = discord.Client()
  14. chosenSub = 'me_irl'
  15. upvoteAmount = 1000
  16. checkCycle = 25
  17.  
  18. @client.event
  19. async def on_ready():
  20. channel = discord.Object(id=230371186020712459)
  21. subreddit = reddit.subreddit(chosenSub)
  22. while not client.is_closed:
  23. for submission in subreddit.hot(limit=checkCycle):
  24. if submission.ups >= upvoteAmount:
  25. if ((submission.url) in open('posts.txt').read()) == False:
  26. posts = open("posts.txt","a")
  27. posts.write(submission.url+"\n")
  28. posts.close()
  29. await client.send_message(channel, submission.url)
  30. time.sleep(10)
  31.  
  32. @client.event
  33. async def on_message(message):
  34. if message.content.startswith('!choosesub'):
  35. await client.send_message(message.channel, 'Reply to me with the name of the sub you choose')
  36. chosenSub = await client.wait_for_message(author=message.author)
  37. await client.send_message(message.channel, 'Thank you', chosenSub, 'has been chosen')
  38. elif message.content.startswith('!chooseup'):
  39. await client.send_message(message.channel, 'Reply to me with the amount of upvotes a post needs for me to send it here')
  40. upvoteAmount = client.wait_for_message(author=message.author)
  41. await client.send_message(message.channel, 'Thank you', upvoteAmount, 'upvotes has been chosen')
  42. elif message.contant.startswith('!howmany'):
  43. await client.send_message(message.channel, 'Reply to me with how many posts I should check from the subreddit each cycle')
  44. checkCycle = client.wait_for_message(authout=message.author)
  45. await client.send_message(message.channel, 'Thank you', checkCycle, 'has been chosen')
  46.  
  47. client.run("MzUyMTQwMTUwMzc1MDU1MzYy.DIiUkw.vHmK8u1LZxx4sq5YFWs7tNj4-8w")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement