mirror of
https://github.com/developersIndia/deviras.git
synced 2024-12-22 16:19:50 +05:30
add flair to showcase sunday thread
This commit is contained in:
parent
1e4f32431c
commit
dda14476df
@ -7,6 +7,7 @@ client_secret = os.environ["REDDIT_CLIENT_SECRET"]
|
|||||||
reddit_pass = os.environ["REDDIT_PASSWORD"]
|
reddit_pass = os.environ["REDDIT_PASSWORD"]
|
||||||
username = os.environ["REDDIT_USERNAME"]
|
username = os.environ["REDDIT_USERNAME"]
|
||||||
user_agent = 'Showcase Sunday Megathread'
|
user_agent = 'Showcase Sunday Megathread'
|
||||||
|
sub = "developersIndia"
|
||||||
|
|
||||||
def is_second_sunday():
|
def is_second_sunday():
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
@ -17,17 +18,29 @@ def is_second_sunday():
|
|||||||
return today == second_sunday
|
return today == second_sunday
|
||||||
|
|
||||||
|
|
||||||
def create_showcase_sunday_megathread(reddit):
|
def create_showcase_sunday_megathread(subreddit):
|
||||||
subreddit = reddit.subreddit("developersIndia")
|
flair = next(
|
||||||
|
filter(
|
||||||
|
lambda flair: flair["flair_text"] == "Showcase Sunday",
|
||||||
|
subreddit.flair.link_templates.user_selectable(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
title = "Showcase Sunday Megathread - {month} {year}".format(month=datetime.date.today().strftime("%B"), year=datetime.date.today().year)
|
title = "Showcase Sunday Megathread - {month} {year}".format(month=datetime.date.today().strftime("%B"), year=datetime.date.today().year)
|
||||||
text = """
|
text = """
|
||||||
Welcome to the Showcase Sunday Megathread!
|
It's time for our monthly showcase thread where we celebrate the incredible talent in our community. Whether it's an app, a website, a tool, or anything else you've built, we want to see it! Share your latest creations, side projects, or even your work-in-progress.
|
||||||
|
|
||||||
|
Let's inspire each other and celebrate the diverse skills we have. Comment below with details about what you've built, the tech stack used, and any interesting challenges faced along the way.
|
||||||
"""
|
"""
|
||||||
sticky = subreddit.submit(title, selftext=text, send_replies=False)
|
|
||||||
sticky.mod.sticky(state=True, bottom=True)
|
submission = subreddit.submit(
|
||||||
# sticky.mod.suggested_sort(sort='new')
|
title,
|
||||||
sticky.mod.flair(text="Megathread")
|
selftext=text,
|
||||||
return sticky.id
|
flair_id=flair["flair_template_id"],
|
||||||
|
)
|
||||||
|
submission.mod.sticky()
|
||||||
|
|
||||||
|
return submission
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
reddit = praw.Reddit(
|
reddit = praw.Reddit(
|
||||||
@ -38,8 +51,10 @@ def main():
|
|||||||
user_agent=user_agent
|
user_agent=user_agent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
subreddit = reddit.subreddit(sub)
|
||||||
|
|
||||||
if is_second_sunday():
|
if is_second_sunday():
|
||||||
create_showcase_sunday_megathread(reddit)
|
create_showcase_sunday_megathread(subreddit)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user