mirror of
https://github.com/developersIndia/deviras.git
synced 2024-11-22 21:23:10 +05:30
use permalink for post + send a message to user
This commit is contained in:
parent
ed2e865492
commit
512a469fde
@ -44,17 +44,37 @@ def update_gist(gist_id, filename, content, description=""):
|
||||
# )
|
||||
# return collection
|
||||
|
||||
# let the author know their post is now part of the collection!
|
||||
def send_message(reddit, username, post_link):
|
||||
message_subject = 'Woohoo! Your post is now part of our community threads collection!'
|
||||
message_text = """
|
||||
Hi there,\n
|
||||
It looks like your [recent post]({post_link}) on r/developersIndia was picked-up by the volunteer team to be part of our curated list of 100+ amazing discussing in the community.\n
|
||||
|
||||
You can find your post in our [Community Threads Collection](https://reddit.com/r/developersIndia/wiki/community-threads).\n
|
||||
|
||||
Feel free to share the collection with your friends and let them know about the amazing discussions happening in our community.\n
|
||||
|
||||
PS: This was an automated messaage, no need to reply. [Reach out to mods](https://www.reddit.com/message/compose?to=/r/developersIndia) if you have any questions.
|
||||
|
||||
Namaste & Keep contributing 🙏
|
||||
"""
|
||||
reddit.redditor(username).message(
|
||||
subject=message_subject, message=message_text.format(post_link=post_link), from_subreddit=reddit.subreddit(sub)
|
||||
)
|
||||
|
||||
def get_post_data(reddit, post_url):
|
||||
submission = reddit.submission(url=post_url)
|
||||
post = {
|
||||
"title": submission.title,
|
||||
"url": submission.url,
|
||||
"url": submission.permalink,
|
||||
"id": submission.id,
|
||||
"num_comments": submission.num_comments,
|
||||
"created_at": datetime.utcfromtimestamp(
|
||||
submission.created_utc
|
||||
).isoformat(),
|
||||
"flair_text": submission.link_flair_text,
|
||||
"author": submission.author.name,
|
||||
}
|
||||
return post
|
||||
|
||||
@ -134,6 +154,8 @@ def main():
|
||||
update_gist(gist_id, "collection.json", json.dumps(collection_json, indent=4))
|
||||
print("Internal database updated successfully!")
|
||||
update_wiki(reddit, "community-threads", posts)
|
||||
send_message(reddit, new_post["author"], new_post["url"])
|
||||
print("Message sent to the author!")
|
||||
else:
|
||||
print("Post is already in the collection. No changes were made.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user