Advertisement
Guest User

Aiden Mist V Rising Reddit Raffle Script

a guest
May 3rd, 2025
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.20 KB | Gaming | 0 0
  1. import praw, random, textwrap, yaml, pytz
  2. from datetime import datetime, timezone, timedelta
  3.  
  4. # Load config
  5. with open("config.yaml") as f:
  6.     c = yaml.safe_load(f)
  7.  
  8. reddit = praw.Reddit(
  9.     client_id=c["client_id"],
  10.     client_secret=c["client_secret"],
  11.     user_agent=c["user_agent"],
  12. )
  13.  
  14. sub = reddit.submission(url=c["post_url"])
  15. sub.comments.replace_more(limit=None)
  16. comments = [cm for cm in sub.comments if hasattr(cm, "body")]
  17.  
  18. now = datetime.now(timezone.utc)
  19. min_age = timedelta(days=c.get("min_account_age_days", 3))
  20. keyword = c.get("required_keyword", "gabagool").lower()
  21. packs = c.get("packs", [])
  22.  
  23. # Build author age map
  24. age_map = {}
  25. for cm in comments:
  26.     if cm.author and cm.author.name not in age_map:
  27.         age_map[cm.author.name] = now - datetime.fromtimestamp(
  28.             cm.author.created_utc, timezone.utc
  29.         )
  30.  
  31. # Filter valid entries
  32. valid = [
  33.     cm
  34.     for cm in comments
  35.     if cm.author
  36.     and keyword in cm.body.lower()
  37.     and age_map.get(cm.author.name, timedelta()) >= min_age
  38. ]
  39.  
  40. if len(valid) < c.get("num_winners", 2):
  41.     print(f"โš ๏ธ Not enough valid entries โ€” found {len(valid)}.")
  42.     exit(1)
  43.  
  44. winners = random.sample(valid, k=c["num_winners"])
  45.  
  46. # Output
  47. et = now.astimezone(pytz.timezone("US/Eastern")).strftime("%B %d at %-I:%M %p ET")
  48. cest = now.astimezone(pytz.timezone("Europe/Berlin")).strftime("%-I:%M %p CEST")
  49.  
  50. print("\n" + "=" * 60)
  51. print("๐ŸŽ‰ V RISING DLC RAFFLE RESULTS ๐ŸŽ‰".center(60))
  52. print("=" * 60)
  53. print(f"โฐ Draw Time: {et} / {cest}\n")
  54. print(
  55.     f"๐Ÿงพ Filter: Only top-level comments containing '{keyword}' from accounts at least {min_age.days} days old.\n"
  56. )
  57.  
  58. for i, w in enumerate(winners):
  59.     age = int(age_map[w.author.name].days)
  60.     print(f"๐Ÿ† Winner #{i+1}:")
  61.     print(f"๐Ÿ‘ค Reddit User: u/{w.author.name} (Account Age: {age} days)")
  62.     print(f"๐ŸŽ Awarded: {packs[i]}")
  63.     print("๐Ÿ—จ๏ธ  Comment:")
  64.     print(
  65.         textwrap.fill(
  66.             w.body.strip(), width=60, initial_indent="   ", subsequent_indent="   "
  67.         )
  68.     )
  69.     print("\n" + "-" * 60 + "\n")
  70.  
  71. print("โœ… Winners will be contacted via Reddit DM")
  72. print("๐Ÿ“Œ Thank you to everyone who entered โ€” stay undead! ๐Ÿฆ‡")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement