Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #24

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions discord_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import json
import re
from typing import Optional
from typing import Optional, List
from dataclasses import dataclass

import discord
Expand All @@ -20,7 +20,7 @@
tree = app_commands.CommandTree(client)
github: Github
repo: Repository
allowed_roles:list[int]|None = None
allowed_roles: List[int]|None = None

state_file_path = "./state.json"
state = {}
Expand All @@ -29,7 +29,7 @@
class SaveSongModal(ui.Modal, title="Save Song"):

song_title = ui.TextInput(label="Song title")
file_name = ui.TextInput(label="Song name")
file_name = ui.TextInput(label="Command name")
author = ui.TextInput(label="Song author")
#notation = ui.Select(options=[SelectOption(label="Modern (bongo+)", value="bongo+"), SelectOption(label="legacy", value="bongo+")])
notation = ui.TextInput(label="Song notation")
Expand Down Expand Up @@ -65,7 +65,7 @@ async def on_submit(self, interaction: Interaction) -> None:
print(self.extras)
print(interaction.message)
file_name = self.file_name.value.strip().replace(".json", "").replace(".", "")
file_name = re.sub(r"\s+", "_", file_name).replace("/", "").replace("\\", "")
file_name = re.sub(r"\s+", "_", file_name).replace("/", "").replace("\\", "").lower()
file_name += ".json"
notation = self.notation.value
if notation == "modern" or notation == "default" or notation == "bongo":
Expand Down Expand Up @@ -122,7 +122,7 @@ def parse_song(message: discord.Message):
notation = "bongo+"

pass
return Song(title, title.replace(" ", "_"), message.author.name, notation, notes)
return Song(title, title.replace(" ", "_").lower(), message.author.name, notation, notes)



Expand Down Expand Up @@ -236,7 +236,7 @@ def read_state():
global state
global state_file_path
if not os.path.isfile(state_file_path):
state = {"last_time": None, "msgs": []}
state = {"last_time": None, "msgs": set()}
return
with open(state_file_path, "r") as state_file:
state_data = json.load(state_file)
Expand Down
2 changes: 1 addition & 1 deletion src/bongocat.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async function playFromGithub(song, user)
let dedications = song.match(userRegex)?.map(s => s.replace("@", ""));
song = song.replaceAll(userRegex, ""); //remove usernames from string
song = song.trim().replaceAll(/\s+/g, "_").replace(/\.json$/, "").replaceAll(".", ""); //remove whitespaces, remove dots

song = song.toLowerCase();
song += ".json";

console.log("Playing", song, "from github for", user);
Expand Down
Loading