forked from WeakAuras/WeakAuras2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Which includes a curated list of thanks + an automatically updated patreon list.
- Loading branch information
1 parent
23c60ca
commit 7f1c7d9
Showing
8 changed files
with
513 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import patreon | ||
from patreon.schemas import pledge | ||
import unicodedata | ||
import os | ||
|
||
def has_cj(text): | ||
for char in text: | ||
for name in ('CJK','CHINESE','KATAKANA',): | ||
if name in unicodedata.name(char): | ||
return True | ||
return False | ||
|
||
def has_k(text): | ||
for char in text: | ||
if "HANGUL" in unicodedata.name(char): | ||
return True | ||
return False | ||
|
||
def get_names(pledges_response, all_pledges, names): | ||
"""Function to add names from all_pledges to names list""" | ||
for pledge in all_pledges: | ||
if pledge.attributes()["declined_since"] == None: | ||
patron_id = pledge.relationship('patron').id() | ||
patron = pledges_response.find_resource_by_type_and_id('user', patron_id) | ||
names.append(patron.attribute('full_name')) | ||
|
||
|
||
api_client = patreon.API(os.environ['PATREON_CREATOR_ACCESS_TOKEN']) | ||
|
||
campaign_id = api_client.fetch_campaign().data()[0].id() | ||
pledges_response = api_client.fetch_page_of_pledges( | ||
campaign_id, | ||
25) | ||
|
||
cursor = None | ||
names = [] | ||
while True: | ||
pledges_response = api_client.fetch_page_of_pledges( | ||
campaign_id, | ||
25, | ||
cursor=cursor, | ||
) | ||
get_names(pledges_response, pledges_response.data(), names) | ||
cursor = api_client.extract_cursor(pledges_response) | ||
if not cursor: | ||
break | ||
|
||
|
||
names.sort(key=lambda y: y.lower()) | ||
|
||
|
||
cjnames = filter(has_cj, names) | ||
knames = filter(lambda n: not has_cj(n) and has_k(n), names) | ||
latinnames = filter(lambda n: not has_cj(n) and not has_k(n), names) | ||
|
||
file = open("WeakAuras/PatreonList.lua", "w") | ||
file.write("if not WeakAuras.IsLibsOK() then return end\n") | ||
file.write("---@type string\n") | ||
file.write("local AddonName = ...\n") | ||
file.write("---@class Private\n") | ||
file.write("local Private = select(2, ...)\n") | ||
|
||
file.write("Private.PatreonsList = {\n") | ||
for name in latinnames: | ||
file.write(" [=[" + name.strip() + "]=],\n") | ||
file.write("}\n") | ||
|
||
file.write("Private.PatreonsListCJ = {\n") | ||
for name in cjnames: | ||
file.write(" [=[" + name.strip() + "]=],\n") | ||
file.write("}\n") | ||
|
||
file.write("Private.PatreonsListK = {\n") | ||
for name in knames: | ||
file.write(" [=[" + name.strip() + "]=],\n") | ||
file.write("}\n") | ||
|
||
file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Create Patreon Update Pull Request | ||
|
||
on: | ||
schedule: | ||
- cron: "0 10 * * 1" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
patreonUpdate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- name: Install patreon pip | ||
run: | | ||
pip install patreon | ||
shell: bash | ||
- name: Update Patreon list | ||
run: | | ||
/usr/bin/env python3 .github/scripts/patreonupate.py | ||
shell: bash | ||
env: | ||
PATREON_CREATOR_ACCESS_TOKEN: ${{ secrets.PATREON_CREATOR_ACCESS_TOKEN}} | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
branch: update-patreonlist | ||
commit-message: Update Patreons List | ||
title: Update Patreon List | ||
body: Update Patreon List | ||
delete-branch: true | ||
|
Binary file not shown.
Oops, something went wrong.