mirror of
https://github.com/developersIndia/deviras.git
synced 2024-12-22 08:09:49 +05:30
✨ script to update titles
This commit is contained in:
parent
16cc8ea1be
commit
8fe3788afb
12
README.md
12
README.md
@ -1,2 +1,14 @@
|
||||
# deviras
|
||||
Bunch of scripts to automate stuff around developersIndia subreddit
|
||||
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
https://praw.readthedocs.io/en/stable/code_overview/other/idcard.html
|
||||
|
||||
|
||||
|
||||
## TODO
|
||||
- Figure out best way to read secrets?
|
||||
- Seprate out titles in a dataset.json
|
||||
|
56
main.py
Normal file
56
main.py
Normal file
@ -0,0 +1,56 @@
|
||||
import praw
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
|
||||
titles = [
|
||||
"ranting about jira",
|
||||
"siting in a meeting",
|
||||
"squashing bugs",
|
||||
"centering divs",
|
||||
"waiting for staging deployment",
|
||||
"writing tests",
|
||||
"pushing directly to prod",
|
||||
"doing code review",
|
||||
"deleting jira tickets",
|
||||
"Creating a pull request",
|
||||
"forgot to run DB migrations",
|
||||
"Broke production",
|
||||
"running on staging ENV",
|
||||
"merging git branches",
|
||||
"releasing the MVP",
|
||||
"finding JIRA tickets"
|
||||
]
|
||||
|
||||
client_id = os.environ["REDDIT_CLIENT_ID"]
|
||||
client_secret = os.environ["REDDIT_CLIENT_SECRET"]
|
||||
reddit_pass = os.environ["REDDIT_PASSWORD"]
|
||||
|
||||
def get_titles():
|
||||
currentlyViewingText, subscribersText = random.sample(titles, 2)
|
||||
return [currentlyViewingText, subscribersText]
|
||||
|
||||
|
||||
def update_titles():
|
||||
reddit = praw.Reddit(
|
||||
client_id=client_id,
|
||||
client_secret=client_secret,
|
||||
password=reddit_pass,
|
||||
user_agent="testscript by u/BhupeshV",
|
||||
username="BhupeshV",
|
||||
)
|
||||
widgets = reddit.subreddit("developersIndia").widgets
|
||||
id_card = widgets.id_card
|
||||
print("Titles Before update")
|
||||
# total members
|
||||
print(id_card.subscribersText)
|
||||
print(id_card.currentlyViewingText)
|
||||
|
||||
titles = get_titles()
|
||||
print(titles)
|
||||
|
||||
widgets.id_card.mod.update(currentlyViewingText=titles[0])
|
||||
widgets.refresh()
|
||||
widgets.id_card.mod.update(subscribersText=titles[1])
|
||||
|
||||
update_titles()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
praw
|
Loading…
Reference in New Issue
Block a user