mirror of
https://github.com/developersIndia/deviras.git
synced 2025-05-31 14:11:43 +05:30
Compare commits
7 Commits
dc7a04b9b1
...
community-
Author | SHA1 | Date | |
---|---|---|---|
a96b150daf | |||
58746803ee | |||
518f650160 | |||
1dad8740e6 | |||
2df84308dd | |||
512a469fde | |||
ed2e865492 |
@ -50,6 +50,15 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "LinearArray",
|
||||||
|
"name": "LinearArray",
|
||||||
|
"avatar_url": "https://github.com/lineararray.png",
|
||||||
|
"profile": "https://github.com/lineararray",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
@ -79,7 +79,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center" valign="top" width="14.28%"><a href="https://animesh-ghosh.github.io/"><img src="https://avatars.githubusercontent.com/u/34956994?v=4?s=100" width="100px;" alt="MaDDogx"/><br /><sub><b>MaDDogx</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=Animesh-Ghosh" title="Code">💻</a> <a href="https://github.com/developersIndia/deviras/commits?author=Animesh-Ghosh" title="Tests">⚠️</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://animesh-ghosh.github.io/"><img src="https://avatars.githubusercontent.com/u/34956994?v=4?s=100" width="100px;" alt="MaDDogx"/><br /><sub><b>MaDDogx</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=Animesh-Ghosh" title="Code">💻</a> <a href="https://github.com/developersIndia/deviras/commits?author=Animesh-Ghosh" title="Tests">⚠️</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://pratham.cc"><img src="https://avatars.githubusercontent.com/u/67585967?v=4?s=100" width="100px;" alt="Pratham"/><br /><sub><b>Pratham</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=git-bruh" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://pratham.cc"><img src="https://avatars.githubusercontent.com/u/67585967?v=4?s=100" width="100px;" alt="Pratham"/><br /><sub><b>Pratham</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=git-bruh" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://nisarga.me/"><img src="https://avatars.githubusercontent.com/u/45588772?v=4?s=100" width="100px;" alt="Nisarga Adhikary"/><br /><sub><b>Nisarga Adhikary</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=ni5arga" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://nisarga.me/"><img src="https://avatars.githubusercontent.com/u/45588772?v=4?s=100" width="100px;" alt="Nisarga Adhikary"/><br /><sub><b>Nisarga Adhikary</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=ni5arga" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://lineararray.nekoweb.org"><img src="https://github.com/lineararray.png" width="100px;" alt="LinearArray"/><br /><sub><b>LinearArray</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=LinearArray" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://reddit.com/u/LinearArray"><img src="https://i.imgur.com/NTzygIr.jpeg" width="100px;" alt="LinearArray"/><br /><sub><b>LinearArray</b></sub></a><br /><a href="https://github.com/developersIndia/deviras/commits?author=LinearArray" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
|
@ -88,6 +88,16 @@ def get_announcement_posts(subreddit):
|
|||||||
return get_posts_by_flair(subreddit, flair["flair_text"])
|
return get_posts_by_flair(subreddit, flair["flair_text"])
|
||||||
|
|
||||||
|
|
||||||
|
def code_collaboration_posts(subreddit):
|
||||||
|
flair = next(
|
||||||
|
filter(
|
||||||
|
lambda flair: "Code Collab" in flair["flair_text"],
|
||||||
|
subreddit.flair.link_templates.user_selectable(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return get_posts_by_flair(subreddit, flair["flair_text"])
|
||||||
|
|
||||||
def get_gist_content(gist_id):
|
def get_gist_content(gist_id):
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"token {token}",
|
"Authorization": f"token {token}",
|
||||||
@ -125,6 +135,7 @@ def create_community_roundup_post(
|
|||||||
weekly_discussion_posts,
|
weekly_discussion_posts,
|
||||||
ama_posts,
|
ama_posts,
|
||||||
announcement_posts,
|
announcement_posts,
|
||||||
|
collab_posts,
|
||||||
):
|
):
|
||||||
flair = next(
|
flair = next(
|
||||||
filter(
|
filter(
|
||||||
@ -145,21 +156,21 @@ The collection is curated by our volunteer team & is independent of the number o
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if len(announcement_posts) > 0:
|
if len(announcement_posts) > 0:
|
||||||
text = "## Announcements\n||\n|--------|\n"
|
text = "## Announcements\n|Announcements from volunteer team|\n|--------|\n"
|
||||||
for post in announcement_posts:
|
for post in announcement_posts:
|
||||||
text += f"| [**{post.title}**]({post.url}) |\n"
|
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
|
||||||
else:
|
else:
|
||||||
print("No announcements found. Skipping")
|
print("No announcements found. Skipping")
|
||||||
|
|
||||||
if len(ama_posts) > 0:
|
if len(ama_posts) > 0:
|
||||||
text += "\n## AMAs\n||\n|--------|\n"
|
text += "\n## AMAs\n|Read insights from guests that joined us for a day |\n|--------|\n"
|
||||||
for post in ama_posts:
|
for post in ama_posts:
|
||||||
text += f"| [**{post.title}**]({post.url}) |\n"
|
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
|
||||||
else:
|
else:
|
||||||
print("No AMAs found. Skipping")
|
print("No AMAs found. Skipping")
|
||||||
|
|
||||||
if len(posts) > 0:
|
if len(posts) > 0:
|
||||||
text += "\n## Community Threads\n|S.No|Discussions started by members|\n|--------|--------|\n"
|
text += "\n## Community Threads\n|S.No|Insightful discussions started by community members|\n|--------|--------|\n"
|
||||||
posts_counter = 0
|
posts_counter = 0
|
||||||
for post in posts:
|
for post in posts:
|
||||||
posts_counter += 1
|
posts_counter += 1
|
||||||
@ -168,16 +179,23 @@ The collection is curated by our volunteer team & is independent of the number o
|
|||||||
print("No posts found in the collection for this month. Skipping")
|
print("No posts found in the collection for this month. Skipping")
|
||||||
|
|
||||||
if len(weekly_discussion_posts) > 0:
|
if len(weekly_discussion_posts) > 0:
|
||||||
text += "\n## Weekly Discussions\n|Started by Volunteer/Mod Team|\n|--------|\n"
|
text += "\n## Weekly Discussions\n|Weekly tech discussions started by Volunteer Team|\n|--------|\n"
|
||||||
for post in weekly_discussion_posts:
|
for post in weekly_discussion_posts:
|
||||||
text += f"| [**{post.title}**]({post.url}) |\n"
|
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
|
||||||
else:
|
else:
|
||||||
print("No weekly discussions found. Skipping")
|
print("No weekly discussions found. Skipping")
|
||||||
|
|
||||||
|
if len(collab_posts) > 0:
|
||||||
|
text += "\n## Code Collab\n|Folks looking for collaborations on hackathons, projects etc.|\n|--------|\n"
|
||||||
|
for post in collab_posts:
|
||||||
|
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
|
||||||
|
else:
|
||||||
|
print("No Code Collaboration posts found. Skipping")
|
||||||
|
|
||||||
if len(i_made_this_posts) > 0:
|
if len(i_made_this_posts) > 0:
|
||||||
text += "\n## I Made This\n|Top 10 posts|\n|--------|\n"
|
text += "\n## I Made This\n|Top 10 projects built by community members|\n|--------|\n"
|
||||||
for post in i_made_this_posts:
|
for post in i_made_this_posts:
|
||||||
text += f"| [**{post.title}**]({post.url}) |\n"
|
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
|
||||||
else:
|
else:
|
||||||
print("No I Made This posts found. Skipping")
|
print("No I Made This posts found. Skipping")
|
||||||
|
|
||||||
@ -213,8 +231,9 @@ def main():
|
|||||||
weekly_discussion_posts = get_weekly_discussion_posts(subreddit)
|
weekly_discussion_posts = get_weekly_discussion_posts(subreddit)
|
||||||
ama_posts = get_ama_posts(subreddit)
|
ama_posts = get_ama_posts(subreddit)
|
||||||
announcement_posts = get_announcement_posts(subreddit)
|
announcement_posts = get_announcement_posts(subreddit)
|
||||||
|
collab_posts = code_collaboration_posts(subreddit)
|
||||||
create_community_roundup_post(
|
create_community_roundup_post(
|
||||||
subreddit, posts, i_made_this_posts, weekly_discussion_posts, ama_posts, announcement_posts
|
subreddit, posts, i_made_this_posts, weekly_discussion_posts, ama_posts, announcement_posts, collab_posts
|
||||||
)
|
)
|
||||||
print("Community Roundup post created successfully!")
|
print("Community Roundup post created successfully!")
|
||||||
else:
|
else:
|
||||||
|
@ -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 one of your [posts]({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). Feel free to share the collection with your dev friends.\n
|
||||||
|
- We post a compilation of these threads every month in [Community Roundups](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22Community%20Roundup%22). Stay tuned for the next one!\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.
|
||||||
|
|
||||||
|
Cheers,\n
|
||||||
|
The r/developersIndia Community Team
|
||||||
|
"""
|
||||||
|
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
|
||||||
|
|
||||||
@ -123,6 +143,7 @@ def main():
|
|||||||
|
|
||||||
new_post = get_post_data(reddit, args.post_url)
|
new_post = get_post_data(reddit, args.post_url)
|
||||||
if new_post["id"] not in saved_collection_ids:
|
if new_post["id"] not in saved_collection_ids:
|
||||||
|
new_post["title"] = new_post["title"].strip()
|
||||||
posts.append(new_post)
|
posts.append(new_post)
|
||||||
posts = sorted(posts, key=lambda k: k["created_at"])
|
posts = sorted(posts, key=lambda k: k["created_at"])
|
||||||
|
|
||||||
@ -134,6 +155,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.")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user