mirror of
https://github.com/developersIndia/deviras.git
synced 2025-05-31 14:11:43 +05:30
Compare commits
1 Commits
dc7a04b9b1
...
remove-col
Author | SHA1 | Date | |
---|---|---|---|
4f9f286e82 |
@ -79,10 +79,8 @@ 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>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
<!-- markdownlint-restore -->
|
||||||
|
@ -51,14 +51,14 @@ def main():
|
|||||||
if question_text != "[deleted]":
|
if question_text != "[deleted]":
|
||||||
question_link = "https://reddit.com" + comment.parent().permalink
|
question_link = "https://reddit.com" + comment.parent().permalink
|
||||||
markdown_file += (
|
markdown_file += (
|
||||||
f"{question_number}. [{question_text}]({question_link})\n\n"
|
f"{question_number}. [{question_text}]({question_link})\n"
|
||||||
) # Add an extra newline after each question
|
)
|
||||||
question_number += 1
|
question_number += 1
|
||||||
|
|
||||||
with open("questions.md", "w", encoding="utf-8") as file:
|
with open("questions.md", "w", encoding="utf-8") as file:
|
||||||
file.write(markdown_file)
|
file.write(markdown_file)
|
||||||
|
|
||||||
print(f"{question_number - 1} questions generated successfully.")
|
print(f"{question_number} questions generated successfully.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -152,7 +152,7 @@ The collection is curated by our volunteer team & is independent of the number o
|
|||||||
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||\n|--------|\n"
|
||||||
for post in ama_posts:
|
for post in ama_posts:
|
||||||
text += f"| [**{post.title}**]({post.url}) |\n"
|
text += f"| [**{post.title}**]({post.url}) |\n"
|
||||||
else:
|
else:
|
||||||
|
@ -75,7 +75,7 @@ def update_wiki(reddit, wikipage, posts):
|
|||||||
|
|
||||||
wiki_header = """# A collection of must read discussions started by community members"""
|
wiki_header = """# A collection of must read discussions started by community members"""
|
||||||
content = wiki_header + "\n\n"
|
content = wiki_header + "\n\n"
|
||||||
content += f"A handpicked collection of **{total_posts}** interesting posts, discussions & high-quality threads gathered over **{total_years-1}** years & counting.\n\n"
|
content += f"A handpicked collection of **{total_posts}** interesting posts, discussions & high-quality threads gathered over **{total_years}** years & counting.\n\n"
|
||||||
content += "If you spot a post that could be in this list, send us a [modmail](https://reddit.com/message/compose?to=r/developersIndia&subject=Community%20Threads%20Collection%20Suggestion&message=Hey%20folks%2C%0A%0A%3Cpost%20link%3E)\n\n"
|
content += "If you spot a post that could be in this list, send us a [modmail](https://reddit.com/message/compose?to=r/developersIndia&subject=Community%20Threads%20Collection%20Suggestion&message=Hey%20folks%2C%0A%0A%3Cpost%20link%3E)\n\n"
|
||||||
|
|
||||||
for year in sorted(posts_by_year.keys(), reverse=True):
|
for year in sorted(posts_by_year.keys(), reverse=True):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import praw
|
import praw
|
||||||
import time
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
client_id = os.environ["REDDIT_CLIENT_ID"]
|
client_id = os.environ["REDDIT_CLIENT_ID"]
|
||||||
@ -20,7 +19,7 @@ def get_last_activity_times(reddit, username):
|
|||||||
limit=100
|
limit=100
|
||||||
): # look at the user's 100 most recent comments
|
): # look at the user's 100 most recent comments
|
||||||
if comment.subreddit.display_name == sub:
|
if comment.subreddit.display_name == sub:
|
||||||
last_comment_time = datetime.datetime.fromtimestamp(comment.created_utc).strftime('%d %B, %Y')
|
last_comment_time = datetime.datetime.fromtimestamp(comment.created_utc)
|
||||||
break
|
break
|
||||||
|
|
||||||
# Get the user's last post creation time and title in the subreddit
|
# Get the user's last post creation time and title in the subreddit
|
||||||
@ -30,7 +29,7 @@ def get_last_activity_times(reddit, username):
|
|||||||
limit=100
|
limit=100
|
||||||
): # look at the user's 100 most recent posts
|
): # look at the user's 100 most recent posts
|
||||||
if submission.subreddit.display_name == sub:
|
if submission.subreddit.display_name == sub:
|
||||||
last_post_time = datetime.datetime.fromtimestamp(submission.created_utc).strftime('%d %B, %Y')
|
last_post_time = datetime.datetime.fromtimestamp(submission.created_utc)
|
||||||
last_post_title = submission.title
|
last_post_title = submission.title
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -46,25 +45,13 @@ def get_current_flair(reddit, username):
|
|||||||
|
|
||||||
return flair["flair_text"], template["id"]
|
return flair["flair_text"], template["id"]
|
||||||
|
|
||||||
def get_flair(reddit, username):
|
|
||||||
subreddit = reddit.subreddit(sub)
|
|
||||||
flair = next(subreddit.flair(username))
|
|
||||||
|
|
||||||
template = get_template_from_flair_text(reddit, flair["flair_text"])
|
|
||||||
|
|
||||||
if template is None:
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
return flair["flair_text"], template["id"]
|
|
||||||
|
|
||||||
def assign_user_flair(reddit, username, flair_text):
|
def assign_user_flair(reddit, username, flair_text):
|
||||||
subreddit = reddit.subreddit(sub)
|
subreddit = reddit.subreddit(sub)
|
||||||
flair = next(subreddit.flair(username))
|
flair = next(subreddit.flair(username))
|
||||||
|
|
||||||
template = get_flair_template_from_text(reddit, flair["flair_text"])
|
template = get_flair_template_from_text(reddit, flair["flair_text"])
|
||||||
# append YoE to the flair text
|
subreddit.flair.set(username, text=flair_text, flair_template_id=template["id"])
|
||||||
verified_text = f"{flair['flair_text']} | {flair_text}"
|
|
||||||
subreddit.flair.set(username, text=verified_text, flair_template_id=template["id"])
|
|
||||||
|
|
||||||
|
|
||||||
def get_flair_templates(reddit):
|
def get_flair_templates(reddit):
|
||||||
@ -79,14 +66,6 @@ def get_flair_template_from_text(reddit, flair_text):
|
|||||||
return template
|
return template
|
||||||
|
|
||||||
|
|
||||||
def get_template_from_flair_text(reddit, flair_text):
|
|
||||||
templates = get_flair_templates(reddit)
|
|
||||||
for template in templates:
|
|
||||||
# check if the flair text is in the template
|
|
||||||
if template["text"] in flair_text:
|
|
||||||
return template
|
|
||||||
|
|
||||||
|
|
||||||
def send_message(reddit, username, flair_text):
|
def send_message(reddit, username, flair_text):
|
||||||
message_subject = 'Woohoo! You are now a verified member of r/developersIndia! 🚀'
|
message_subject = 'Woohoo! You are now a verified member of r/developersIndia! 🚀'
|
||||||
message_text = """
|
message_text = """
|
||||||
@ -138,14 +117,8 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
# get current flair
|
# get current flair
|
||||||
current_flair_text, current_flair_template_id = get_flair(reddit, reddit_username)
|
current_flair_text, current_flair_template_id = get_current_flair(reddit, reddit_username)
|
||||||
|
if current_flair_text is None:
|
||||||
# TODO figure out final flair text
|
|
||||||
if "Verified" in current_flair_text or "YoE" in current_flair_text:
|
|
||||||
print(f"{reddit_username} is already verified")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
if current_flair_text is None and current_flair_template_id is None:
|
|
||||||
print(f"{reddit_username} does not have a flair on r/developersIndia")
|
print(f"{reddit_username} does not have a flair on r/developersIndia")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
@ -158,11 +131,8 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
assign_user_flair(reddit, reddit_username, flair_text)
|
assign_user_flair(reddit, reddit_username, flair_text)
|
||||||
# Ya I know, just don't ask
|
print(f"Updated {reddit_username}'s flair to \"{flair_text}\"")
|
||||||
time.sleep(2)
|
send_message(reddit, reddit_username, flair_text)
|
||||||
updated_flair_text, _ = get_flair(reddit, reddit_username)
|
|
||||||
print(f"Updated {reddit_username}'s flair to \"{updated_flair_text}\"")
|
|
||||||
send_message(reddit, reddit_username, updated_flair_text)
|
|
||||||
print(f"Sent verification confirmation message to {reddit_username}")
|
print(f"Sent verification confirmation message to {reddit_username}")
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user