Skip to content

Commit

Permalink
chore!: prefix twitter-related env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed May 13, 2024
1 parent 49c76aa commit 8dbddbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
USER=
PASS=
EMAIL=
TW_USER=
TW_PASS=
TW_EMAIL=
10 changes: 5 additions & 5 deletions .github/workflows/fetch_tweets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
- name: Fetch tweets
run: python -m x_notes.fetch_tweets
env:
USER: ${{ secrets.USER }}
PASS: ${{ secrets.PASS }}
EMAIL: ${{ secrets.EMAIL }}
PROXY: ${{ secrets.PROXY }}
COOKIES: ${{ secrets.COOKIES }}
TW_USER: ${{ secrets.USER }}
TW_PASS: ${{ secrets.PASS }}
TW_EMAIL: ${{ secrets.EMAIL }}
TW_PROXY: ${{ secrets.PROXY }}
TW_COOKIES: ${{ secrets.COOKIES }}
UPDATE_SECRET: 1
GH_TOKEN: ${{ secrets.GH_TOKEN }}
REPO: ${{ github.repository }}
Expand Down
16 changes: 8 additions & 8 deletions x_notes/tweets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ def log_stats(notes: dict[str, dict[str, Any]]) -> None:

async def login() -> API:
api = API(
proxy=environ.get("PROXY"),
proxy=environ.get("TW_PROXY"),
raise_when_no_account=True,
)

username = environ["USER"]
username = environ["TW_USER"]
account_kwargs = {
"username": username,
"password": environ["PASS"],
"email": environ["EMAIL"],
"password": environ["TW_PASS"],
"email": environ["TW_EMAIL"],
"email_password": "",
}
cookies = environ.get("COOKIES")
cookies = environ.get("TW_COOKIES")
if cookies:
logger.info("Cookie found. No need to log in")
account_kwargs["cookies"] = cookies
Expand Down Expand Up @@ -71,12 +71,12 @@ async def fetch_tweets() -> None:
except NoAccountError:
logger.info("Rate limited – giving up")
break
account = await api.pool.get(environ["USER"])
account = await api.pool.get(environ["TW_USER"])
if not account.active:
logger.info("Failed to fetch tweet")
if environ.get("COOKIES"):
if environ.get("TW_COOKIES"):
await api.pool.delete_inactive()
del environ["COOKIES"]
del environ["TW_COOKIES"]
api = await login()
continue
note_update = {
Expand Down

0 comments on commit 8dbddbb

Please sign in to comment.