Skip to content

Commit

Permalink
make it so it adds pack.json also add template
Browse files Browse the repository at this point in the history
  • Loading branch information
coopeeo authored Mar 28, 2024
1 parent e9ce0ae commit 83badd6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blank_issues_enabled: false
contact_links:
- name: Discord Community
about: "Chat with us: https://discord.gg/RwbRP8ADdc"
about: "Chat with us: https://discord.gg/RwbRP8ADdc"
22 changes: 2 additions & 20 deletions .github/ISSUE_TEMPLATE/new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,12 @@ labels: []
body:
- type: markdown
attributes:
value: "## Click Sounds Request"
- type: input
id: name
attributes:
label: Click Sound Name
description: put your click sound name here
placeholder: Click Sound Name
validations:
required: true
- type: dropdown
id: type
attributes:
label: Type of Click Sound
description: Choose what type your Click Sound is. is it useful or is it a meme sound?
options:
- Useful
- Meme
validations:
required: true
value: "# Click Sounds Request"
- type: textarea
id: zip
attributes:
label: Add Pack
description: Add your click sound files here in a **COMPRESSED *ZIP* FILE**, NOTHING ELSE
description: Add your click sound files here in a **COMPRESSED *ZIP* FILE**, NOTHING ELSE (ZIP FILE MUST INCLUDE A pack.json FILE)
placeholder: Input files here
validations:
required: true
53 changes: 53 additions & 0 deletions .github/download_file2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import json
import hashlib
import os
import sys
import zipfile
import urllib.request
import re
from pathlib import Path
import subprocess
import time

def fail(msg):
print(f'Fail: {msg}', file=sys.stderr)
sys.exit(1)


def sanitize_name(name):
return ((((''.join(c for c in name if c.isalnum() or c in ['.'] or c in [' '] or c in ['_'] or c in ['-']))).replace(" ", "_")).replace("-", "_")).replace(".", "_").replace("Clicks", "")


def save(clickName, folderName, ee):
print(clickName)
print(folderName)
print(ee)
if os.getenv('GITHUB_OUTPUT'):
with open(os.getenv('GITHUB_OUTPUT'), 'a') as file:
file.write(f'click_name={clickName}\nfolder={folderName}\ntype={ee}\n')

issue_body = os.environ['ISSUE_BODY'].replace("\r", "")

if 'Click Sound Name' not in issue_body or "Add Pack" not in issue_body:
print('Not a valid entry', file=sys.stderr)
sys.exit(2)

try:
match = re.search(r'\s*?### Add Pack\s*?(\S+)\s*?', issue_body)
#print(match)
time.sleep(2)
if match:
click_url = matchfound[(matchfound.find("(") + 1):-1]
urllib.request.urlretrieve(click_url, 'test/' + folderName + '.zip')
clickName = match2.group(1)
folderName = sanitize_name(clickName)
matchfound = match.group(1)
typee = match3.group(1)
if typee != "Useful" and typee != "Meme":
fail('Click Type must be \"Useful\" or \"Release\"')
save(clickName, folderName, typee)
else:
fail(f'Could not find the zip link')

except Exception as inst:
fail(f'Could not download the zip file: {inst}')
4 changes: 4 additions & 0 deletions .github/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def send_webhook():
shutil.copy(os.path.join(os.path.join("test/", folderName), x), os.path.join(clicks_folder, filename))
if "Releases" in listdir or "releases" in listdir or "release" in listdir or "Release" in listdir:
shutil.copy(os.path.join(os.path.join("test/", folderName), x), os.path.join(releases_folder, filename))
if x.endswith("pack.json"):
filename = x.split("/")
filename = filename[len(filename) - 1]
shutil.copy(os.path.join("test/", x), os.path.join(version_mod_directory, filename))

except Exception as inst:
fail(f'Could not populate click folder {version_mod_directory}: {inst}')
Expand Down
Binary file added Click_Sound_Template.zip
Binary file not shown.

0 comments on commit 83badd6

Please sign in to comment.