26 Commits

Author SHA1 Message Date
Bhupesh Varshney
3feccf6755 Update aoc.yml 2025-01-10 00:17:12 +05:30
Bhupesh-V
101b529307 🐛 fix: handle case for no announcements 2024-12-31 22:06:21 +05:30
Bhupesh-V
e9a454fa5a I apologise, my bad 2024-12-06 21:19:53 +05:30
Bhupesh-V
345dc1016e use Annonymous user instead of None 2024-12-05 18:07:37 +05:30
Bhupesh-V
2824227ac9 remove private link 2024-12-01 12:48:14 +05:30
Bhupesh-V
e84b1b18ae fix env reference 2024-12-01 12:45:37 +05:30
Bhupesh Varshney
a73d956b23 make Advent of Code leaderboard generic (#21) 2024-11-30 10:43:34 +05:30
Bhupesh-V
bcb037076a reduce title noise 2024-11-08 13:43:20 +05:30
Bhupesh-V
8ceaefcce9 improve mail copy 2024-11-06 14:19:06 +05:30
Bhupesh-V
7237ed4e02 new script - wiki mention notifier 2024-11-06 00:07:19 +05:30
Bhupesh-V
ea7b0e8a37 update community threads, auto-message 2024-11-01 20:21:36 +05:30
Bhupesh Varshney
aeed19753e Update README.md 2024-10-18 22:30:40 +05:30
Bhupesh-V
87cd738f3e update hiring post title to mega-thread 2024-10-17 22:11:40 +05:30
Bhupesh-V
676744cb6f fix newline issues in community roundup post description 2024-10-04 19:54:30 +05:30
Bhupesh-V
3b6d74c683 fix typo 2024-09-14 18:07:34 +05:30
Bhupesh-V
282d02d000 dont message if empty use 2024-08-15 16:21:34 +05:30
Bhupesh-V
7c90a350e9 fix empty user 2024-08-15 16:17:47 +05:30
Bhupesh-V
24be5dcd82 add link to i made this and showcase sunday 2024-08-15 15:01:16 +05:30
Bhupesh-V
bcd0648167 ignore csv fiels 2024-07-29 13:39:25 +05:30
Bhupesh-V
50a57664ba increase projects count to 20 + filter deleted posts 2024-07-29 13:39:25 +05:30
LinearArray
44d765927c fix lineararray image (link broke due to username change) 2024-07-17 19:59:26 +05:30
Bhupesh-V
069293ea5e remove un-necessary stuff 2024-07-12 14:59:47 +05:30
Bhupesh Varshney
4e26a3f764 add more relatable titles! 2024-07-08 14:29:28 +05:30
Bhupesh-V
17967c3b95 upto post title format for community roundups 2024-05-13 14:03:50 +05:30
Bhupesh-V
10ce6e5528 rollback to default permissions for discord bot 2024-05-13 14:01:54 +05:30
LinearArray
f2b11ddd21 Update README.md 2024-05-06 20:08:51 +05:30
15 changed files with 191 additions and 86 deletions

View File

@@ -1,9 +1,9 @@
name : AoC leaderboard
name: AoC leaderboard
on:
# schedule:
# Every 2 hours
# - cron: '0 */2 * * *'
# Run every 24 hours at 00:00 UTC
# - cron: "0 0 * * *"
workflow_dispatch:
permissions:
@@ -23,7 +23,7 @@ jobs:
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Update Learderboard
- name: Update Leaderboard
env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
@@ -31,7 +31,8 @@ jobs:
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
AOC_SESSION_COOKIE: ${{ secrets.AOC_SESSION_COOKIE }}
AOC_LEADERBOARD_CODE: ${{ secrets.AOC_LEADERBOARD_CODE }}
REDDIT_POST_ID: ${{ secrets.REDDIT_POST_ID }}
AOC_LEADERBOARD_REDDIT_POST_ID: ${{ secrets.AOC_LEADERBOARD_REDDIT_POST_ID }}
AOC_YEAR: ${{ secrets.AOC_YEAR }}
run: |
cd aoc
python main.py

35
.github/workflows/wiki-mention.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name : Wiki Mention Notifier
on:
workflow_dispatch:
inputs:
username:
description: 'The username of the community member to notify'
required: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Update Wiki
env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
run: |
cd wiki-mention
python main.py ${{ github.event.inputs.username }}

2
.gitignore vendored
View File

@@ -127,3 +127,5 @@ dmypy.json
# Pyre type checker
.pyre/
*.csv

View File

@@ -21,7 +21,7 @@
### [community-threads](https://github.com/developersIndia/deviras/blob/main/community-threads/main.py)
- Used for grabbing the posts from [community threads collection](https://www.reddit.com/r/developersIndia/collection/958aef35-f9cb-414d-ab33-08bc639e47de/) and adding it to the [wiki](https://www.reddit.com/r/developersIndia/wiki/community-threads/).
- Add a post to [community threads wiki](https://www.reddit.com/r/developersIndia/wiki/community-threads/).
- ![action build](https://github.com/developersIndia/deviras/actions/workflows/collection-thread-updater.yml/badge.svg)
### [job-thread](https://github.com/developersIndia/deviras/blob/main/job-thread/main.py)

View File

@@ -6,20 +6,21 @@ client_id = os.environ["REDDIT_CLIENT_ID"]
client_secret = os.environ["REDDIT_CLIENT_SECRET"]
reddit_pass = os.environ["REDDIT_PASSWORD"]
username = os.environ["REDDIT_USERNAME"]
user_agent = 'AdventOfCode Leaderboard Updater (by https://github.com/ni5arga/)'
user_agent = 'AdventOfCode Leaderboard Updater - developersIndia'
aoc_session_cookie = os.environ["AOC_SESSION_COOKIE"]
aoc_leaderboard_code = os.environ["AOC_LEADERBOARD_CODE"]
reddit_post_id = os.environ.get("REDDIT_POST_ID")
aoc_year = os.environ.get("AOC_YEAR")
reddit_post_id = os.environ.get("AOC_LEADERBOARD_REDDIT_POST_ID")
aoc_url = f'https://adventofcode.com/{{year}}/leaderboard/private/view/{aoc_leaderboard_code}.json'
aoc_url = f'https://adventofcode.com/{aoc_year}/leaderboard/private/view/{aoc_leaderboard_code}.json'
def get_leaderboard_data():
response = requests.get(aoc_url.format(year=2023), cookies={'session': aoc_session_cookie})
response = requests.get(aoc_url.format(year=aoc_year), cookies={'session': aoc_session_cookie})
data = response.json()
return data
def format_leaderboard(data, num_players=100):
leaderboard_stats = "r/developersIndia Advent of Code Leaderboard Stats\n\n"
leaderboard_stats = f"r/developersIndia Advent of Code {aoc_year} - Leaderboard\n\n"
leaderboard_stats += "| Rank | Player | Stars | Score |\n"
leaderboard_stats += "|------|--------|-------|-------|\n"
@@ -30,9 +31,12 @@ def format_leaderboard(data, num_players=100):
for i, member_data in enumerate(sorted_members[:num_players]):
# check for non-zero local_score
if member_data['local_score'] > 0:
# if member's name is null, use the member_id
if member_data['name'] == None:
member_data['name'] = f"Anonymous #{member_data['id']}"
leaderboard_stats += f"| {i + 1} | {member_data['name']} | {member_data['stars']} | {member_data['local_score']} |\n"
leaderboard_stats += f"\n[Advent of Code Leaderboard](https://adventofcode.com/2023/leaderboard/private/view/{aoc_leaderboard_code})\n"
leaderboard_stats += f"\nUpdated every 24 hours"
return leaderboard_stats
@@ -43,7 +47,7 @@ def update_reddit_post(reddit, post_id, new_stats):
def main():
if not reddit_post_id:
print("Please set the REDDIT_POST_ID environment variable.")
print("Please set the AOC_LEADERBOARD_REDDIT_POST_ID environment variable.")
return
reddit = praw.Reddit(
@@ -55,9 +59,7 @@ def main():
)
leaderboard_data = get_leaderboard_data()
formatted_stats = format_leaderboard(leaderboard_data)
update_reddit_post(reddit, reddit_post_id, formatted_stats)
if __name__ == "__main__":

View File

@@ -2,17 +2,18 @@
## Required Environment Variables
1. `REDDIT_CLIENT_ID`: Reddit API client ID.
2. `REDDIT_CLIENT_SECRET`: Reddit API client secret.
3. `REDDIT_PASSWORD`: Reddit account password.
4. `REDDIT_USERNAME`: Reddit account username.
5. `AOC_SESSION_COOKIE`: Session cookie for the Advent of Code website.
6. `AOC_LEADERBOARD_CODE`: Code for the Advent of Code leaderboard.
7. `REDDIT_POST_ID`: ID of Reddit post which is used as leaderboard.
7. `AOC_LEADERBOARD_REDDIT_POST_ID`: ID of Reddit post which is used as leaderboard.
----
## Instructions on how to get `AOC_SESSION_COOKIE`
1. **Create an Advent of Code Account:**
- If you don't have an Advent of Code account, go to the [Advent of Code website](https://adventofcode.com/), and sign up for an account.
@@ -41,8 +42,4 @@
9. **Use the Session Cookie:**
- Paste the copied session cookie value into the appropriate environment variable (`AOC_SESSION_COOKIE` in this case) in your code or set it as an environment variable.
![session-cookie](https://github.com/ni5arga/deviras/blob/main/aoc/cookie.png?raw=true)
![session-cookie](https://raw.githubusercontent.com/developersindia/deviras/refs/heads/main/aoc/cookie.png)

View File

@@ -27,7 +27,7 @@ def get_posts_by_flair(subreddit, flair):
posts = []
for post in subreddit.search(f'flair_name:"{flair}"', time_filter="month"):
post_date = datetime.datetime.fromtimestamp(post.created_utc)
if post_date.year == current_year and post_date.month == current_month:
if post_date.year == current_year and post_date.month == current_month and post.selftext != '[deleted]':
post.title = post.title.replace("|", "\\|") # Escape the "|" character
posts.append(post)
@@ -74,7 +74,7 @@ def get_i_made_this_posts(subreddit):
)
# Return only the top 10 posts
return posts[:10]
return posts[:20]
def get_announcement_posts(subreddit):
@@ -144,7 +144,7 @@ def create_community_roundup_post(
)
)
title = "Community Roundup: List of must read posts & discussions that happened this month - {month} {year}".format(
title = "Community Roundup: List of interesting discussions that happened in {month} {year}".format(
month=datetime.date.today().strftime("%B"), year=datetime.date.today().year
)
@@ -154,6 +154,7 @@ def create_community_roundup_post(
**Community Roundup is posted on the last day of each month. To explore a compilation of all interesting posts and community threads over time, [visit our wiki](https://www.reddit.com/r/developersIndia/wiki/community-threads/).**\n
The collection is curated by our volunteer team & is independent of the number of upvotes and comments (except for "I made This" posts). If you believe we may have overlooked any engaging posts or discussions, please share them with us via [modmail](https://reddit.com/message/compose?to=r/developersIndia&subject=Community%20Threads%20Collection%20Suggestion&message=Hey%20folks%2C%0A%0A%3Cpost%20link%3E).\n
"""
text = ""
if len(announcement_posts) > 0:
text = "## Announcements\n|Announcements from volunteer team|\n|--------|\n"
@@ -193,7 +194,8 @@ The collection is curated by our volunteer team & is independent of the number o
print("No Code Collaboration posts found. Skipping")
if len(i_made_this_posts) > 0:
text += "\n## I Made This\n|Top 10 projects built by community members|\n|--------|\n"
text += "\n## I Made This\n\nFind more projects & builders on our [Showcase Sunday Megathreads](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22Showcase%20Sunday%20%3Asnoo_hearteyes%3A%22)\n\n"
text += "|Top 20 projects built by community members|\n|--------|\n"
for post in i_made_this_posts:
text += f"| [**{post.title.strip()}**]({post.url}) |\n"
else:

View File

@@ -49,12 +49,11 @@ 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
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 200+ amazing discussions 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
- We post a compilation of these threads every month-end 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
@@ -74,7 +73,7 @@ def get_post_data(reddit, post_url):
submission.created_utc
).isoformat(),
"flair_text": submission.link_flair_text,
"author": submission.author.name,
"author": submission.author.name if submission.author else "",
}
return post
@@ -155,8 +154,12 @@ 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)
if new_post["author"]:
send_message(reddit, new_post["author"], new_post["url"])
print("Message sent to the author!")
else:
print("Author username is empty. No message sent.")
else:
print("Post is already in the collection. No changes were made.")

View File

@@ -14,7 +14,7 @@ def create_discord_event(
EVENT_END_TIME,
):
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
@bot.event
async def on_ready():
@@ -46,7 +46,7 @@ def create_discord_event(
location=EVENT_LOCATION,
privacy_level=discord.PrivacyLevel.guild_only,
)
print("Discord Event: ", event.url)
print("Discord Event created: ", event.url)
except Exception as e:
print(e)

View File

@@ -50,7 +50,7 @@ def create_google_calendar_event(
event = service.events().insert(calendarId=calendar_id, body=event).execute()
print("Google calendar: %s" % (event.get("htmlLink")))
print("Calendar event created: %s" % (event.get("htmlLink")))
return event
except Exception as e:

View File

@@ -2,28 +2,22 @@
"titles": [
"wrestling with Jira",
"trapped in endless meetings",
"exterminating code critters",
"centering divs for fun",
"impatiently waiting on staging",
"crafting elegant tests",
"yolo pushing to prod",
"code review detectives",
"assassinating Jira tickets",
"forging majestic pull requests",
"DB migration amnesiacs",
"lgtm",
"LGTM",
"staging environment warriors",
"taming wild git branches",
"unleashing the MVP",
"Jira ticket treasure hunters",
"jira ticket treasure hunters",
"merge conflict negotiators",
"absorbing knowledge transfer",
"absorbing KTs",
"purging container hoarders",
"bug creators and breadwinners",
"DSA explorers",
"escaping Vim's clutches",
"indexing database maestros",
"YAML whisperers",
"debugging code in dreams",
"refactoring like it's an art",
"living on Stack Overflow",
@@ -42,6 +36,13 @@
"refining their Google-fu",
"upgrading their tech stacks",
"writing self-documenting code",
"drowning in technical debt"
"drowning in technical debt",
"stuck on git merge",
"asking for PR reviews",
"finding DB backups",
"venting about YAML",
"not writing unit tests",
"writing unit tests",
"think TDD is a joke"
]
}

View File

@@ -23,13 +23,13 @@ class Config:
SUBREDDIT = "developersindia"
POST_FLAIR = "Hiring"
POST_TITLE = f"Don't Miss Out on These Job Opportunities | Weekly Job Openings Thread | {strftime(STRFTIME_FORMAT)}"
POST_TITLE = f"Don't Miss Out on These Job Opportunities | Job Openings Mega-thread | {strftime(STRFTIME_FORMAT)}"
POST_TEXT = """\
This thread has all the latest job openings that haven't been posted on previous weekly threads.
This thread has all the latest job openings that haven't been posted on previous hiring mega threads.
If you have a job opening that you'd like to share with the community, you can post it using this link:- https://developersindia.in/post-a-job/
For all the available job openings, check out the Job Board at:- https://developersindia.in/job-board/
- If you have a job opening that you'd like to share with the community, you can post it using [this link](https://developersindia.in/post-a-job/).
- For all the available job openings, check out our [Job Board](https://developersindia.in/job-board/).
- If you are looking for work, consider participating in our monthly ["Hire Me" megathreads](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22Hire%20Me%22).
Stay tuned for updates on the latest job openings, and apply for the ones that interest you. Wishing you the best of luck in your job search!\
"""

View File

@@ -28,11 +28,13 @@ def create_showcase_sunday_megathread(subreddit):
title = "Showcase Sunday Megathread - {month} {year}".format(month=datetime.date.today().strftime("%B"), year=datetime.date.today().year)
text = """
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.
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. Ask for feedback, and help each other out.
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.
**Showcase Sunday thread is posted on the second Sunday of every month. You can find the [schedule on our calendar](https://developersindia.in/events-calendar).**
### [Looking for more projects built by developersIndia community members?](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22I%20Made%20This%20%3Asnoo_wink%3A%22)
**Showcase Sunday thread is posted on the second Sunday of every month. You can find the [schedule on our calendar](https://developersindia.in/events-calendar). You can also find past [showcase sunday megathreads here](https://www.reddit.com/r/developersIndia/?f=flair_name%3A%22Showcase%20Sunday%20%3Asnoo_hearteyes%3A%22)**.
"""
submission = subreddit.submit(

View File

@@ -75,7 +75,7 @@ old_flairs_total_count = sum(old_available_flair_count.values())
# print(f"Total count of user-flairs: {total_count + emoji_flair_count + old_flairs_total_count}")
data = {
'Users with un-supported (old) text flairs': f"**{old_flairs_total_count}**",
'Users with custom text flairs': f"**{old_flairs_total_count}**",
'Users with supported text flairs': f"**{total_count}**",
'Users with emoji only flairs': f"**{emoji_flair_count}**",
'Total count of user-flairs': f"**{total_count + emoji_flair_count + old_flairs_total_count}**"

60
wiki-mention/main.py Normal file
View File

@@ -0,0 +1,60 @@
import praw
import os
# Reddit API credentials
client_id = os.environ["REDDIT_CLIENT_ID"]
client_secret = os.environ["REDDIT_CLIENT_SECRET"]
reddit_pass = os.environ["REDDIT_PASSWORD"]
username = os.environ["REDDIT_USERNAME"]
user_agent = "Wiki Mention Notifier"
sub = "developersIndia"
# Create a Reddit instance
reddit = praw.Reddit(
client_id=client_id,
client_secret=client_secret,
password=reddit_pass,
user_agent=user_agent,
username=username,
)
def send_message(reddit, username):
message_subject = 'Woohoo! Your advice/perspective is now part of our wiki!'
message_text = """
Hi there,\n
It looks like one of your comments on r/developersIndia was picked-up by the volunteer team to be part of our **[community-driven wiki](https://wiki.developersindia.in/)**.\n
- You can find your contribution by searching your username in the [Wiki](https://wiki.developersindia.in/).\n
- We can't thank you enough for your valuable contribution to our community 🧡\n\n
Please keep contributing productively. If you have any questions/concerns feel free to reply to this mail or create a new modmail.\n\n
Cheers,\n
The r/developersIndia Community Team
"""
reddit.redditor(username).message(
subject=message_subject, message=message_text, from_subreddit=reddit.subreddit(sub)
)
def add_mod_note_good_contributor(reddit, username):
subreddit = reddit.subreddit(sub)
subreddit.mod.notes.create(
redditor=username,
label="HELPFUL_USER",
note="Their advice/perspective was mentioned in our wiki.",
)
def main():
if len(os.sys.argv) != 2:
print("Usage: python main.py <username>")
return
reddit_username = os.sys.argv[1]
send_message(reddit, reddit_username)
add_mod_note_good_contributor(reddit, reddit_username)
print(f"Sent wiki mention modmail to {reddit_username}")
if __name__ == "__main__":
main()