smartel99

fixed version

Jul 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. async def check_for_new_post(bot):
  2.     global subscriptions
  3.  
  4.     # TODO: Fetch data from file
  5.     # subscriptions = get_file()
  6.     # if subscriptions != 'None':
  7.  
  8.     await bot.wait_until_ready()
  9.     while not bot.is_closed:
  10.         for idx, subscription in enumerate(subscriptions):
  11.             sub = read_it_on_reddit.sub_exists(subscription.subreddit)
  12.             new_posts = read_it_on_reddit.get_newest_post(subscription.subreddit)
  13.  
  14.             for new_post in new_posts:
  15.                 if subscriptions[idx].old_post != new_post.fullname:
  16.                     subscriptions[idx] = subscriptions[idx]._replace(old_post=new_post.fullname)
  17.  
  18.                     await bot.send_message(subscription.channel,
  19.                                            embed=read_it_on_reddit.create_embed("New post from:", new_post, sub))
  20.         await asyncio.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment