mirror of
https://github.com/developersIndia/deviras.git
synced 2024-11-23 05:33:12 +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
|
# 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):
|
def get_post_data(reddit, post_url):
|
||||||
submission = reddit.submission(url=post_url)
|
submission = reddit.submission(url=post_url)
|
||||||
post = {
|
post = {
|
||||||
"title": submission.title,
|
"title": submission.title,
|
||||||
"url": submission.url,
|
"url": submission.permalink,
|
||||||
"id": submission.id,
|
"id": submission.id,
|
||||||
"num_comments": submission.num_comments,
|
"num_comments": submission.num_comments,
|
||||||
"created_at": datetime.utcfromtimestamp(
|
"created_at": datetime.utcfromtimestamp(
|
||||||
submission.created_utc
|
submission.created_utc
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
"flair_text": submission.link_flair_text,
|
"flair_text": submission.link_flair_text,
|
||||||
|
"author": submission.author.name,
|
||||||
}
|
}
|
||||||
return post
|
return post
|
||||||
|
|
||||||
@ -134,6 +154,8 @@ def main():
|
|||||||
update_gist(gist_id, "collection.json", json.dumps(collection_json, indent=4))
|
update_gist(gist_id, "collection.json", json.dumps(collection_json, indent=4))
|
||||||
print("Internal database updated successfully!")
|
print("Internal database updated successfully!")
|
||||||
update_wiki(reddit, "community-threads", posts)
|
update_wiki(reddit, "community-threads", posts)
|
||||||
|
send_message(reddit, new_post["author"], new_post["url"])
|
||||||
|
print("Message sent to the author!")
|
||||||
else:
|
else:
|
||||||
print("Post is already in the collection. No changes were made.")
|
print("Post is already in the collection. No changes were made.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user