From bc339a2671463a63f2a9a306c2dec001989d7798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:22:36 +0900 Subject: [PATCH 01/28] Upload New File --- keys.env | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 keys.env diff --git a/keys.env b/keys.env new file mode 100644 index 0000000..43dd235 --- /dev/null +++ b/keys.env @@ -0,0 +1,7 @@ +SLIPSTREAM_OPENROUTER_KEY=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 +DISCORD_TOKEN="MTM2MTgwNTE3MjkxNzE0MTgzNQ.G1II_V.OhJx67VHlKHBj4gCWTTbQoI45T0rfL2gtk15vs" +AI1_API_KEY="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" +SERVICE_KEY="2359" +GENIUS_API_KEY = "spwrTZ3d4KGmczcxSVlgkH7q5b4CE0cDJ2EudX57dHJ74d5ce60IKCxJNQ8o4nJBcIelHd-nne5_6dv2Z-R9oA" +AI_API_KEY = "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" +SERP_API_KEY, = "134ecd1798cd4853cf70a4a4a055f9bcd3bda45e9731b66fe6a16748c3462e57" \ No newline at end of file From f329503cbc2c4630dc1a47fb4aa8b12ff759ce44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:24:02 +0900 Subject: [PATCH 02/28] Edit bot.py --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 83036cb..944ef09 100644 --- a/bot.py +++ b/bot.py @@ -32,7 +32,7 @@ sys.stderr = DualStream(sys.stderr, log_file) print("Logging started.") # Load environment variables -load_dotenv("/home/server/keys.env") +load_dotenv("keys.env") discord_token = os.getenv("DISCORD_TOKEN") # Ensure token is set From 0b6ce45d4f0b2441aabfeadffce73db6000c147f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:39:20 +0900 Subject: [PATCH 03/28] Add new file --- pip.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 pip.txt diff --git a/pip.txt b/pip.txt new file mode 100644 index 0000000..5de44a4 --- /dev/null +++ b/pip.txt @@ -0,0 +1 @@ +pip install aiohappyeyeballs==2.6.1 aiohttp==3.11.16 aiosignal==1.3.2 annotated-types==0.6.0 anyio==4.9.0 archspec==0.2.3 async-timeout==5.0.1 attrs==25.3.0 beautifulsoup4==4.13.4 blis==1.3.0 boltons==24.1.0 Brotli==1.1.0 catalogue==2.0.10 certifi==2025.1.31 cffi==1.17.1 charset-normalizer==3.3.2 ChatterBot==1.2.6 chatterbot-corpus==1.2.2 click==8.1.8 cloudpathlib==0.21.0 confection==0.1.5 cryptography==43.0.3 cymem==2.0.11 decorator==5.2.1 discord.py==2.5.2 distro==1.9.0 docx2pdf==0.1.8 et_xmlfile==2.0.0 fastapi==0.115.12 filelock==3.18.0 frozendict==2.4.2 frozenlist==1.5.0 fsspec==2025.3.2 GPUtil==1.4.0 greenlet==3.2.1 h11==0.14.0 hf-xet==1.1.1 httpcore==1.0.8 httpx==0.28.1 huggingface-hub==0.31.1 idna==3.7 imageio==2.37.0 imageio-ffmpeg==0.6.0 inflate64==1.0.1 inquirerpy==0.3.4 Jinja2==3.1.6 jiter==0.9.0 jsonpatch==1.33 jsonpointer==2.1 langcodes==3.5.0 language_data==1.3.0 lxml==5.4.0 lyricsgenius==3.6.2 marisa-trie==1.2.1 markdown-it-py==2.2.0 MarkupSafe==3.0.2 mathparse==0.1.5 mdurl==0.1.0 moviepy==2.1.2 mpmath==1.3.0 multidict==6.4.3 multivolumefile==0.2.3 murmurhash==1.0.12 networkx==3.4.2 numpy==2.2.5 nvidia-cublas-cu12==12.6.4.1 nvidia-cuda-cupti-cu12==12.6.80 nvidia-cuda-nvrtc-cu12==12.6.77 nvidia-cuda-runtime-cu12==12.6.77 nvidia-cudnn-cu12==9.5.1.17 nvidia-cufft-cu12==11.3.0.4 nvidia-cufile-cu12==1.11.1.6 nvidia-curand-cu12==10.3.7.77 nvidia-cusolver-cu12==11.7.1.2 nvidia-cusparse-cu12==12.5.4.2 nvidia-cusparselt-cu12==0.6.3 nvidia-nccl-cu12==2.26.2 nvidia-nvjitlink-cu12==12.6.85 nvidia-nvtx-cu12==12.6.77 openai==0.28.0 opencv-python==4.11.0.86 openpyxl==3.1.5 openrouter==1.0 packaging==24.2 pfzy==0.3.4 pillow==10.4.0 platformdirs==3.10.0 pluggy==1.5.0 preshed==3.0.9 proglog==0.1.12 prompt_toolkit==3.0.51 propcache==0.3.1 psutil==7.0.0 py7zr==0.22.0 pybcj==1.0.6 pycosat==0.6.6 pycparser==2.21 pycryptodomex==3.23.0 pydantic==2.10.3 pydantic_core==2.27.1 pydub==0.25.1 Pygments==2.15.1 PyNaCl==1.5.0 PyPDF2==3.0.1 pyppmd==1.1.1 PySocks==1.7.1 python-dateutil==2.9.0.post0 python-docx==1.1.2 python-dotenv==1.1.0 python-pptx==1.0.2 PyYAML==6.0.2 pyzstd==0.17.0 regex==2024.11.6 requests==2.32.3 rich==13.9.4 ruamel.yaml==0.18.6 ruamel.yaml.clib==0.2.8 rule34==1.8.1 safetensors==0.5.3 setuptools==75.8.0 shellingham==1.5.4 six==1.17.0 smart-open==7.1.0 sniffio==1.3.1 soupsieve==2.7 spacy==3.8.5 spacy-legacy==3.0.12 spacy-loggers==1.0.5 SQLAlchemy==2.0.40 srsly==2.5.1 starlette==0.46.2 sympy==1.14.0 texttable==1.7.0 thinc==8.3.6 tokenizers==0.21.1 torch==2.7.0 tqdm==4.67.1 transformers==4.51.3 triton==3.3.0 truststore==0.10.0 typer==0.15.2 typing_extensions==4.13.2 urllib3==2.3.0 uvicorn==0.34.2 wasabi==1.1.3 wcwidth==0.2.13 weasel==0.4.1 wheel==0.45.1 whois==1.20240129.2 wrapt==1.17.2 XlsxWriter==3.2.3 yarl==1.19.0 youtube-dl==2021.12.17 zstandard==0.23.0 \ No newline at end of file From 113e9969ddae8d693c11f355895c8947be843ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:50:56 +0900 Subject: [PATCH 04/28] Edit bot.py --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 944ef09..4db977b 100644 --- a/bot.py +++ b/bot.py @@ -98,7 +98,7 @@ def catch_exceptions(func): # Load cog files dynamically async def load_cogs(): - for filename in os.listdir("/home/server/wdiscordbotserver/cogs/"): + for filename in os.listdir("cogs"): if filename.endswith(".py"): try: await bot.load_extension(f"cogs.{filename[:-3]}") From dbab715239ccbb6b51451258fac5f6b18fca74c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:51:48 +0900 Subject: [PATCH 05/28] Delete serverconfig.py --- cogs/serverconfig.py | 161 ------------------------------------------- 1 file changed, 161 deletions(-) delete mode 100644 cogs/serverconfig.py diff --git a/cogs/serverconfig.py b/cogs/serverconfig.py deleted file mode 100644 index 25545c4..0000000 --- a/cogs/serverconfig.py +++ /dev/null @@ -1,161 +0,0 @@ -import discord -from discord.ext import commands -from discord import app_commands -import os -import json - -# Path to the JSON config file -CONFIG_FILE = "/home/server/serverconfig.json" - -def load_config() -> dict: - """Load the server configuration from file. - If the file does not exist or is invalid, create a new empty configuration.""" - if not os.path.exists(CONFIG_FILE): - with open(CONFIG_FILE, "w") as f: - json.dump({}, f) - return {} - try: - with open(CONFIG_FILE, "r") as f: - return json.load(f) - except json.JSONDecodeError: - return {} - -def save_config(data: dict) -> None: - """Save the configuration JSON to file.""" - with open(CONFIG_FILE, "w") as f: - json.dump(data, f, indent=4) - -async def global_disabled_check(interaction: discord.Interaction) -> bool: - """ - Global check for all app (slash) commands. - If the command (except for serverconfig itself) is marked as disabled in this serverβs config, - send an ephemeral message and prevent execution. - """ - # If interaction comes from a DM, allow it. - if interaction.guild is None: - return True - - # Always allow the serverconfig command so admins can change settings. - if interaction.command and interaction.command.name == "serverconfig": - return True - - config = load_config() - guild_id = str(interaction.guild.id) - disabled_commands = config.get(guild_id, []) - - if interaction.command and interaction.command.name in disabled_commands: - if not interaction.response.is_done(): - await interaction.response.send_message( - "This command has been disabled by server admins.", ephemeral=True - ) - # Raising a CheckFailure prevents the command from running. - raise app_commands.CheckFailure("Command disabled.") - return True - -class ServerConfigCog(commands.Cog): - def __init__(self, bot: commands.Bot): - self.bot = bot - - @app_commands.command( - name="serverconfig", - description="Enable or disable a command in this server." - ) - @app_commands.describe( - command="The name of the command to configure", - enabled="Type 'yes' to enable or 'no' to disable." - ) - async def serverconfig( - self, - interaction: discord.Interaction, - command: str, - enabled: str - ): - # Check if the user has admin permissions. - if not interaction.user.guild_permissions.administrator: - await interaction.response.send_message( - "You do not have permission to use this command.", - ephemeral=True - ) - return - - # Normalize the enabled flag. - enabled_flag = enabled.lower() - if enabled_flag not in ["yes", "no"]: - await interaction.response.send_message( - "Invalid 'enabled' option. Please use 'yes' or 'no'.", - ephemeral=True - ) - return - - # Verify that the provided command exists. - found = False - # Check the classic text commands. - for cmd in self.bot.commands: - if cmd.name == command: - found = True - break - # Also check application (slash) commands from the tree. - if not found: - for cmd in self.bot.tree.get_commands(): - if cmd.name == command: - found = True - break - if not found: - await interaction.response.send_message( - f"The command '{command}' was not found.", - ephemeral=True - ) - return - - # Load the configuration. - config = load_config() - guild_id = str(interaction.guild.id) - if guild_id not in config: - config[guild_id] = [] - - if enabled_flag == "no": - # Add the command to the disabled list if not already present. - if command not in config[guild_id]: - config[guild_id].append(command) - save_config(config) - await interaction.response.send_message( - f"Command '{command}' has been **disabled** in this server.", - ephemeral=True - ) - else: # enabled_flag == "yes" - # Remove the command from the disabled list if present. - if command in config[guild_id]: - config[guild_id].remove(command) - save_config(config) - await interaction.response.send_message( - f"Command '{command}' has been **enabled** in this server.", - ephemeral=True - ) - - @serverconfig.autocomplete("command") - async def command_autocomplete( - self, interaction: discord.Interaction, current: str - ) -> list[app_commands.Choice[str]]: - """ - Autocomplete for the 'command' parameter. - It searches both classic and slash commands for matches. - """ - choices = set() - # Get names of text commands. - for cmd in self.bot.commands: - choices.add(cmd.name) - # Get names of app commands. - for cmd in self.bot.tree.get_commands(): - choices.add(cmd.name) - # Filter and send at most 25 matching choices. - filtered = [ - app_commands.Choice(name=cmd, value=cmd) - for cmd in choices - if current.lower() in cmd.lower() - ] - return filtered[:25] - -async def setup(bot: commands.Bot): - # Register the global check β it will run for every application (slash) command. - bot.tree.interaction_check = global_disabled_check - await bot.add_cog(ServerConfigCog(bot)) From d5fbbf5074e2599239ceb0593318671476fc5fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:52:19 +0900 Subject: [PATCH 06/28] Edit randomgpu.py --- cogs/randomgpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/randomgpu.py b/cogs/randomgpu.py index bbc0d88..1d63923 100644 --- a/cogs/randomgpu.py +++ b/cogs/randomgpu.py @@ -7,7 +7,7 @@ import random class GPU(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - self.gpu_file = "/home/server/wdiscordbotserver/data/allgpus.json" + self.gpu_file = "allgpus.json" self.gpus = self.load_gpus() def load_gpus(self): From 1c4f0d3aac68cae3f7b0d185ba5b0d58bafee2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 04:53:07 +0900 Subject: [PATCH 07/28] Edit randomphone.py --- cogs/randomphone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/randomphone.py b/cogs/randomphone.py index dad6f1c..54cd1d7 100644 --- a/cogs/randomphone.py +++ b/cogs/randomphone.py @@ -12,7 +12,7 @@ class RandomPhoneCog(commands.Cog): def load_devices(self): try: - with open("/home/server/wdiscordbotserver/data/devices.json", "r") as f: + with open("devices.json", "r") as f: data = json.load(f) return data.get("RECORDS", []) except Exception as e: From 08247d89e4afb7d788f7803bd3136b242a581fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 05:40:11 +0900 Subject: [PATCH 08/28] Add new file --- setup.sh | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 setup.sh diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..bfa6029 --- /dev/null +++ b/setup.sh @@ -0,0 +1,181 @@ +#!/bin/bash +# This script updates the system, installs required system packages, +# clones the Discord bot repository, sets up a Python virtual environment, +# installs Python dependencies, and finally runs the bot. + +# Exit immediately if a command exits with a non-zero status. +set -e + +echo "Updating package lists and installing system dependencies..." +sudo apt update +sudo apt install python3.12-venv -y +sudo apt-get install python3-pip -y + +echo "Cloning the Discord bot repository..." +git clone https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git + +echo "Setting up the Python virtual environment..." +python3 -m venv venv +# Activate the virtual environment so that subsequent pip installs are local +source venv/bin/activate + +echo "Installing Python dependencies..." +pip install \ + aiohappyeyeballs==2.6.1 \ + aiohttp==3.11.16 \ + aiosignal==1.3.2 \ + annotated-types==0.6.0 \ + anyio==4.9.0 \ + archspec==0.2.3 \ + async-timeout==5.0.1 \ + attrs==25.3.0 \ + beautifulsoup4==4.13.4 \ + blis==1.3.0 \ + boltons==24.1.0 \ + Brotli==1.1.0 \ + catalogue==2.0.10 \ + certifi==2025.1.31 \ + cffi==1.17.1 \ + charset-normalizer==3.3.2 \ + ChatterBot==1.2.6 \ + chatterbot-corpus==1.2.2 \ + click==8.1.8 \ + cloudpathlib==0.21.0 \ + confection==0.1.5 \ + cryptography==43.0.3 \ + cymem==2.0.11 \ + decorator==5.2.1 \ + discord.py==2.5.2 \ + distro==1.9.0 \ + docx2pdf==0.1.8 \ + et_xmlfile==2.0.0 \ + fastapi==0.115.12 \ + filelock==3.18.0 \ + frozendict==2.4.2 \ + frozenlist==1.5.0 \ + fsspec==2025.3.2 \ + GPUtil==1.4.0 \ + greenlet==3.2.1 \ + h11==0.14.0 \ + hf-xet==1.1.1 \ + httpcore==1.0.8 \ + httpx==0.28.1 \ + huggingface-hub==0.31.1 \ + idna==3.7 \ + imageio==2.37.0 \ + imageio-ffmpeg==0.6.0 \ + inflate64==1.0.1 \ + inquirerpy==0.3.4 \ + Jinja2==3.1.6 \ + jiter==0.9.0 \ + jsonpatch==1.33 \ + jsonpointer==2.1 \ + langcodes==3.5.0 \ + language_data==1.3.0 \ + lxml==5.4.0 \ + lyricsgenius==3.6.2 \ + marisa-trie==1.2.1 \ + markdown-it-py==2.2.0 \ + MarkupSafe==3.0.2 \ + mathparse==0.1.5 \ + mdurl==0.1.0 \ + moviepy==2.1.2 \ + mpmath==1.3.0 \ + multidict==6.4.3 \ + multivolumefile==0.2.3 \ + murmurhash==1.0.12 \ + networkx==3.4.2 \ + numpy==2.2.5 \ + nvidia-cublas-cu12==12.6.4.1 \ + nvidia-cuda-cupti-cu12==12.6.80 \ + nvidia-cuda-nvrtc-cu12==12.6.77 \ + nvidia-cuda-runtime-cu12==12.6.77 \ + nvidia-cudnn-cu12==9.5.1.17 \ + nvidia-cufft-cu12==11.3.0.4 \ + nvidia-cufile-cu12==1.11.1.6 \ + nvidia-curand-cu12==10.3.7.77 \ + nvidia-cusolver-cu12==11.7.1.2 \ + nvidia-cusparse-cu12==12.5.4.2 \ + nvidia-cusparselt-cu12==0.6.3 \ + nvidia-nccl-cu12==2.26.2 \ + nvidia-nvjitlink-cu12==12.6.85 \ + nvidia-nvtx-cu12==12.6.77 \ + openai==0.28.0 \ + opencv-python==4.11.0.86 \ + openpyxl==3.1.5 \ + openrouter==1.0 \ + packaging==24.2 \ + pfzy==0.3.4 \ + pillow==10.4.0 \ + platformdirs==3.10.0 \ + pluggy==1.5.0 \ + preshed==3.0.9 \ + proglog==0.1.12 \ + prompt_toolkit==3.0.51 \ + propcache==0.3.1 \ + psutil==7.0.0 \ + py7zr==0.22.0 \ + pybcj==1.0.6 \ + pycosat==0.6.6 \ + pycparser==2.21 \ + pycryptodomex==3.23.0 \ + pydantic==2.10.3 \ + pydantic_core==2.27.1 \ + pydub==0.25.1 \ + Pygments==2.15.1 \ + PyNaCl==1.5.0 \ + PyPDF2==3.0.1 \ + pyppmd==1.1.1 \ + PySocks==1.7.1 \ + python-dateutil==2.9.0.post0 \ + python-docx==1.1.2 \ + python-dotenv==1.1.0 \ + python-pptx==1.0.2 \ + PyYAML==6.0.2 \ + pyzstd==0.17.0 \ + regex==2024.11.6 \ + requests==2.32.3 \ + rich==13.9.4 \ + ruamel.yaml==0.18.6 \ + ruamel.yaml.clib==0.2.8 \ + rule34==1.8.1 \ + safetensors==0.5.3 \ + setuptools==75.8.0 \ + shellingham==1.5.4 \ + six==1.17.0 \ + smart-open==7.1.0 \ + sniffio==1.3.1 \ + soupsieve==2.7 \ + spacy==3.8.5 \ + spacy-legacy==3.0.12 \ + spacy-loggers==1.0.5 \ + SQLAlchemy==2.0.40 \ + srsly==2.5.1 \ + starlette==0.46.2 \ + sympy==1.14.0 \ + texttable==1.7.0 \ + thinc==8.3.6 \ + tokenizers==0.21.1 \ + torch==2.7.0 \ + tqdm==4.67.1 \ + transformers==4.51.3 \ + triton==3.3.0 \ + truststore==0.10.0 \ + typer==0.15.2 \ + typing_extensions==4.13.2 \ + urllib3==2.3.0 \ + uvicorn==0.34.2 \ + wasabi==1.1.3 \ + wcwidth==0.2.13 \ + weasel==0.4.1 \ + wheel==0.45.1 \ + whois==1.20240129.2 \ + wrapt==1.17.2 \ + XlsxWriter==3.2.3 \ + yarl==1.19.0 \ + youtube-dl==2021.12.17 \ + zstandard==0.23.0 + +echo "Changing directory to the cloned repository and starting the bot..." +cd wdiscordbot-internal-server-aws +python3 bot.py \ No newline at end of file From 7733363b70e50cfcd3831007dc823cbda615e830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 07:42:29 +0900 Subject: [PATCH 09/28] Edit update.py --- cogs/update.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cogs/update.py b/cogs/update.py index 8e59bd7..aaff472 100644 --- a/cogs/update.py +++ b/cogs/update.py @@ -16,9 +16,9 @@ class GitUpdateCog(commands.Cog): await interaction.response.send_message("You do not have permission to run this command.", ephemeral=True) return await interaction.response.send_message("Initiating update. The bot will restart shortly...") - target_dir = "/home/server/wdiscordbotserver/" - repo_url = "https://gitlab.com/pancakes1234/wdiscordbotserver.git" - restart_script = "/home/server/wdiscordbotserver/bot.py" + target_dir = "./wdiscordbot-internal-server-aws" + repo_url = "https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git" + restart_script = "./wdiscordbot-internal-server-aws/bot.py" try: if os.path.exists(target_dir): From bd3410929b1edb2efe28447face0ed3cfdcfd59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 22 May 2025 07:44:01 +0900 Subject: [PATCH 10/28] Edit update.py --- cogs/update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/update.py b/cogs/update.py index aaff472..fc7b198 100644 --- a/cogs/update.py +++ b/cogs/update.py @@ -16,9 +16,9 @@ class GitUpdateCog(commands.Cog): await interaction.response.send_message("You do not have permission to run this command.", ephemeral=True) return await interaction.response.send_message("Initiating update. The bot will restart shortly...") - target_dir = "./wdiscordbot-internal-server-aws" + target_dir = "~/wdiscordbot-internal-server-aws" repo_url = "https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git" - restart_script = "./wdiscordbot-internal-server-aws/bot.py" + restart_script = "~/wdiscordbot-internal-server-aws/bot.py" try: if os.path.exists(target_dir): From 110a45d39a3e7d109b68ade0f210596dd06e3516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Sat, 24 May 2025 20:29:28 +0900 Subject: [PATCH 11/28] Edit update.py --- cogs/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/update.py b/cogs/update.py index fc7b198..ed67f57 100644 --- a/cogs/update.py +++ b/cogs/update.py @@ -18,7 +18,7 @@ class GitUpdateCog(commands.Cog): await interaction.response.send_message("Initiating update. The bot will restart shortly...") target_dir = "~/wdiscordbot-internal-server-aws" repo_url = "https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git" - restart_script = "~/wdiscordbot-internal-server-aws/bot.py" + restart_script = "home/ubuntu/wdiscordbot-internal-server-aws/bot.py" try: if os.path.exists(target_dir): From fa873a559d0815cb98629b982437d57b4b99fc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Tue, 27 May 2025 03:22:59 +0900 Subject: [PATCH 12/28] Edit ai.py --- cogs/ai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/ai.py b/cogs/ai.py index 0df7b2d..d8324d8 100644 --- a/cogs/ai.py +++ b/cogs/ai.py @@ -43,7 +43,7 @@ class ImprovedAICog(commands.Cog): # Configuration self.default_config = { - "model": "meta-llama/llama-4-maverick:free", + "model": "google/gemini-2.5-flash-preview-05-20", "temperature": 0.75, "max_tokens": 1500, "top_p": 0.9, From 8e8541bab91f3bf940d23cc055baa784384fe45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Tue, 27 May 2025 20:15:57 +0900 Subject: [PATCH 13/28] Update file update.py --- cogs/update.py | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/cogs/update.py b/cogs/update.py index ed67f57..900c9e8 100644 --- a/cogs/update.py +++ b/cogs/update.py @@ -10,36 +10,50 @@ class GitUpdateCog(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - @app_commands.command(name="update", description="Updates the bot code from GitLab and restarts the bot. (Admin Only)") + @app_commands.command( + name="update", + description="Updates the bot code from GitLab and restarts the bot. (Admin Only)" + ) async def update(self, interaction: discord.Interaction): + # Check for administrator permission if not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You do not have permission to run this command.", ephemeral=True) return - await interaction.response.send_message("Initiating update. The bot will restart shortly...") - target_dir = "~/wdiscordbot-internal-server-aws" - repo_url = "https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git" - restart_script = "home/ubuntu/wdiscordbot-internal-server-aws/bot.py" + # Respond with an initial message + await interaction.response.send_message("Initiating update. The bot will restart shortly...", ephemeral=True) + + # Define absolute paths and repository URL + target_dir = "/home/ubuntu/wdiscordbot-internal-server-aws" + repo_url = "https://gitlab.com/pancakes1234/wdiscordbot-internal-server-aws.git" + restart_script = "/home/ubuntu/wdiscordbot-internal-server-aws/bot.py" + try: if os.path.exists(target_dir): shutil.rmtree(target_dir) - await interaction.edit_original_response(content=f"Removed directory: {target_dir}") + await interaction.followup.send(f"Removed directory: {target_dir}", ephemeral=True) else: - await interaction.edit_original_response(content=f"Directory {target_dir} does not exist; proceeding with clone...") + await interaction.followup.send(f"Directory {target_dir} does not exist; proceeding with clone...", ephemeral=True) + + # Clone the repository subprocess.run(["git", "clone", repo_url, target_dir], check=True) - await interaction.edit_original_response(content="Repository cloned successfully.") + await interaction.followup.send("Repository cloned successfully.", ephemeral=True) except Exception as e: error_msg = f"Update failed: {e}" print(error_msg) - await interaction.edit_original_response(content=error_msg) + await interaction.followup.send(error_msg, ephemeral=True) return + try: - await interaction.edit_original_response(content="Bot has updated to the latest commit and is restarting...") + await interaction.followup.send("Bot has updated to the latest commit and is restarting...", ephemeral=True) + # Optionally change working directory if your bot expects it: + os.chdir(target_dir) + # Restart the bot by replacing the current process with the new version os.execv(sys.executable, [sys.executable, restart_script]) - # If os.execv returns, it means it failed except Exception as e: - await interaction.edit_original_response(content=f"Failed to restart bot: {e}") - + error_msg = f"Failed to restart bot: {e}" + print(error_msg) + await interaction.followup.send(error_msg, ephemeral=True) async def setup(bot: commands.Bot): await bot.add_cog(GitUpdateCog(bot)) From 78ff3f3c5822310967f56d4eb528cf732aec34c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 29 May 2025 00:12:23 +0900 Subject: [PATCH 14/28] Edit randomphone.py From 3924c934943811d3668a64b0f914b94da52cc489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B6=E3=82=AB=E3=83=AA=E3=82=A2=E3=82=B9=E3=83=BB?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=83=AA=E3=82=A2=E3=83=A0=E3=83=BB=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=83=BC?= <26689019-pancakes1234@users.noreply.gitlab.com> Date: Thu, 29 May 2025 00:34:32 +0900 Subject: [PATCH 15/28] Edit index.php --- API/index.php | 320 ++++++++++++++++++++++++++++---------------------- 1 file changed, 179 insertions(+), 141 deletions(-) diff --git a/API/index.php b/API/index.php index 706d4ce..e45c86f 100644 --- a/API/index.php +++ b/API/index.php @@ -1,21 +1,50 @@ true, + 'secure' => true, // Ensure HTTPS is used in production + 'samesite' => 'Strict' +]); session_start(); -// === Login & Authentication === -// Only proceed if the current session is authenticated. -// If not, show a login form. -if (!isset($_SESSION['logged_in'])) { - if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username'], $_POST['password'])) { - $user_env = getenv('user'); // environment variable "user" - $pass_env = getenv('pass'); // environment variable "pass" - if ($_POST['username'] === $user_env && $_POST['password'] === $pass_env) { - $_SESSION['logged_in'] = true; - header("Location: index.php"); - exit; +// --- CSRF Utility Functions --- +function getCsrfToken() { + if (empty($_SESSION['csrf_token'])) { + $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); + } + return $_SESSION['csrf_token']; +} + +function validateCsrfToken($token) { + return isset($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token); +} + +// --- Login and Authentication --- +if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { + if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username'], $_POST['password'], $_POST['csrf_token'])) { + if (!validateCsrfToken($_POST['csrf_token'])) { + $error = "Invalid CSRF token."; } else { - $error = "Invalid credentials."; + $envUser = getenv('user'); + $envPass = getenv('pass'); + // Using hash_equals for timing attack prevention + if (hash_equals($_POST['username'], $envUser) && hash_equals($_POST['password'], $envPass)) { + $_SESSION['logged_in'] = true; + session_regenerate_id(true); + header("Location: " . $_SERVER['PHP_SELF']); + exit; + } else { + $error = "Invalid credentials."; + } } } + $loginToken = getCsrfToken(); ?> @@ -64,8 +93,9 @@ if (!isset($_SESSION['logged_in'])) {