Skip to content

Commit 3a97bbf

Browse files
committed
Refactor file paths to use 'private' directory instead of 'ScratchOn_private', change root to the ScratchOn folder directly.
1 parent 8355c27 commit 3a97bbf

11 files changed

Lines changed: 28 additions & 26 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
__pycache__/
44
# Hide environment variables
55
*.env
6-
scratchblocks
6+
7+
scratchblocks
8+
private

chatbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def answer(query: str, username: str):
4040

4141

4242
# Setup scratch connection (temporarily ignored to avoid bugs with Scratch API)
43-
# with open("ScratchOn_private/password.txt") as f:
43+
# with open("private/password.txt") as f:
4444
# session = sa.login(username="_Scratch-On_", password=f.readlines()[0])
4545

4646
# profile = session.connect_linked_user()

commands/experimental_commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def toggle_ping(interact: discord.Interaction):
4242
found = False
4343
i = -1
4444

45-
with open("ScratchOn_private/dcusers.txt") as file:
45+
with open("private/dcusers.txt") as file:
4646
for item in file.readlines():
4747
i += 1
4848
if item.strip() == target:
@@ -52,14 +52,14 @@ async def toggle_ping(interact: discord.Interaction):
5252
print(i)
5353

5454
if found:
55-
with open("ScratchOn_private/scusers.txt") as file:
55+
with open("private/scusers.txt") as file:
5656
s_user = file.readlines()[i]
5757
print(s_user)
5858
target = s_user
5959
found = False
6060
i = 0
6161

62-
with open("ScratchOn_private/users2ping.txt") as file:
62+
with open("private/users2ping.txt") as file:
6363
for item in file.readlines():
6464
i += 1
6565
if item.strip() == target:
@@ -77,7 +77,7 @@ async def toggle_ping(interact: discord.Interaction):
7777
)
7878
)
7979
else:
80-
with open("ScratchOn_private/users2ping.txt", "a+") as file:
80+
with open("private/users2ping.txt", "a+") as file:
8181
file.write(f"{s_user}\n")
8282
update_pings()
8383
await interact.response.send_message(

commands/project_commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ async def s_download(interact: discord.Interaction, project: str):
179179
id = "".join(filter(str.isdigit, project))
180180
await interact.response.defer()
181181
proj = scratch.get_project(id)
182-
proj.download(filename="project.sb3", dir="ScratchOn_private")
182+
proj.download(filename="project.sb3", dir="private")
183183

184184
await interact.followup.send(
185185
file=discord.File(
186-
fp="ScratchOn_private/project.sb3", filename=f"{proj.title}.sb3"
186+
fp="private/project.sb3", filename=f"{proj.title}.sb3"
187187
)
188188
)
189189

190-
os.remove(path="ScratchOn_private/project.sb3")
190+
os.remove(path="private/project.sb3")

commands/user_commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ async def s_profile(interact: discord.Interaction, user: str):
4040
else:
4141
rank = "<:ScratchCat:1330547949721223238> Scratcher"
4242

43-
with open("ScratchOn_private/scusers.txt") as f:
43+
with open("private/scusers.txt") as f:
4444
lines = [line.rstrip("\n") for line in f]
4545
if usr.name in lines:
4646
idx = lines.index(usr.name)
4747
binded = (
48-
open("ScratchOn_private/dcusers.txt").readlines()[idx].rstrip("\n")
48+
open("private/dcusers.txt").readlines()[idx].rstrip("\n")
4949
)
5050
else:
5151
binded = "*No binded account found*"
@@ -114,7 +114,7 @@ async def bind(interact: discord.Interaction, username: str):
114114
found = False
115115

116116
# Check if user is already binded
117-
with open("ScratchOn_private/dcusers.txt") as file:
117+
with open("private/dcusers.txt") as file:
118118
for item in file.readlines():
119119
if item.strip() == target:
120120
found = True
@@ -150,9 +150,9 @@ async def bind(interact: discord.Interaction, username: str):
150150
v = pending_verifiers[user_id]
151151
if v.check():
152152
# Store binding
153-
with open("ScratchOn_private/dcusers.txt", "a") as file:
153+
with open("private/dcusers.txt", "a") as file:
154154
file.write(f"{str(interact.user)}\n")
155-
with open("ScratchOn_private/scusers.txt", "a") as file:
155+
with open("private/scusers.txt", "a") as file:
156156
file.write(f"{str(username)}\n")
157157

158158
# Remove verifier from memory

database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import duckdb
66

77
# Database connection
8-
db = duckdb.connect("ScratchOn_private/ScratchOn.duckdb")
8+
db = duckdb.connect("private/ScratchOn.duckdb")
99

1010
# Initialize table
1111
db.execute("""CREATE TABLE IF NOT EXISTS ScratchOn (

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def main():
2727
"""Run the bot."""
28-
with open("ScratchOn_private/token.txt") as f:
28+
with open("private/token.txt") as f:
2929
token = f.readlines()[0].strip()
3030
bot.run(token)
3131

services/blockbits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
# Login to Scratch (temporarily ignored to avoid bugs with Scratch API)
13-
# with open("ScratchOn_private/password.txt") as f:
13+
# with open("private/password.txt") as f:
1414
# session = sa.login(username="_Scratch-On_", password=f.readlines()[0])
1515

1616
# Connect to the Blockbit project's cloud variables

services/scratchblocks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import os
66
from pyppeteer import launch
77

8-
TEMPLATE_PATH = "ScratchOn/scratchblocks_template.html"
8+
TEMPLATE_PATH = "scratchblocks_template.html"
99

1010

1111
async def render_blocks_image(
12-
code: str, style: str, output_path: str = "ScratchOn_private/blocks.png"
12+
code: str, style: str, output_path: str = "private/blocks.png"
1313
) -> str:
1414
"""
1515
Renders scratchblocks code to an image.
@@ -35,15 +35,15 @@ async def render_blocks_image(
3535
# Update scratchblocks path
3636
html = html.replace(
3737
"scratchblocks/build/scratchblocks.min.js",
38-
"../ScratchOn_private/scratchblocks/build/scratchblocks.min.js",
38+
"../private/scratchblocks/build/scratchblocks.min.js",
3939
)
4040
html = html.replace(
4141
"scratchblocks/build/translations-all.js",
42-
"../ScratchOn_private/scratchblocks/build/translations-all.js",
42+
"../private/scratchblocks/build/translations-all.js",
4343
)
4444

4545
# Save modified HTML to a temporary file
46-
temp_path = "ScratchOn_private/temp_scratchblocks.html"
46+
temp_path = "private/temp_scratchblocks.html"
4747
with open(temp_path, "w", encoding="utf-8") as f:
4848
f.write(html)
4949

topGG.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ async def sync_commands(self, guild_id: Optional[int] = None) -> int:
325325
return 0
326326

327327

328-
def attach_to_bot(bot: commands.Bot, env_path: str = "ScratchOn/TopGG.env"):
328+
def attach_to_bot(bot: commands.Bot, env_path: str = "TopGG.env"):
329329
"""Attach Top.gg integration to an existing `commands.Bot` instance.
330330
331331
This will:

0 commit comments

Comments
 (0)