about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2024-10-27 21:33:15 +0300
committerNakidai <nakidai@disroot.org>2024-10-27 21:33:15 +0300
commit38acd533869bdaac60af9636d087a2f9f9d59e0f (patch)
tree6321c7dfa62ae5ad60f19cb05a009fa3f3fdebae
parentd87503d0242737c4514c4b15849884138f5a48f2 (diff)
downloadpetthecord-38acd533869bdaac60af9636d087a2f9f9d59e0f.tar.gz
petthecord-38acd533869bdaac60af9636d087a2f9f9d59e0f.zip
Add origin parameter
-rw-r--r--src/petthecord/bot.py9
-rw-r--r--src/petthecord/main.py7
2 files changed, 13 insertions, 3 deletions
diff --git a/src/petthecord/bot.py b/src/petthecord/bot.py
index 9f8e975..666c336 100644
--- a/src/petthecord/bot.py
+++ b/src/petthecord/bot.py
@@ -6,8 +6,9 @@ from .server import Server
 
 
 class PatTheCordCog(commands.Cog):
-    def __init__(self, client: commands.Bot) -> None:
+    def __init__(self, client: commands.Bot, origin: str = "https://ptc.pwn3t.ru") -> None:
         self.client = client
+        self.origin = origin
 
     @app_commands.allowed_installs(users=True)
     @app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
@@ -26,7 +27,7 @@ class PatTheCordCog(commands.Cog):
         user: User,
         r: str = ""
     ) -> None:
-        await interaction.response.send_message(f"https://ptc.nakidai.ru/{user.id}.{r}.gif")
+        await interaction.response.send_message(f"{self.origin}/{user.id}.{r}.gif")
 
 
 class Bot(commands.Bot):
@@ -35,6 +36,7 @@ class Bot(commands.Bot):
 
         host: str = "127.0.0.1",
         port: int = 8080,
+        origin: str = "https://ptc.pwn3t.ru",
         caching: bool = True,
         cache_path: str = "/var/cache/petthecord",
         cache_lifetime: int = 86400,
@@ -46,13 +48,14 @@ class Bot(commands.Bot):
         )
         self._host = host
         self._port = port
+        self._origin = origin
         self._caching = caching
         self._cache_path = cache_path
         self._cache_lifetime = cache_lifetime
         self._cache_gc_delay = cache_gc_delay
 
     async def on_ready(self) -> None:
-        await self.add_cog(PatTheCordCog(self))
+        await self.add_cog(PatTheCordCog(self, self._origin))
         await self.tree.sync()
 
         server = Server(
diff --git a/src/petthecord/main.py b/src/petthecord/main.py
index 2e2047a..a1bc1a6 100644
--- a/src/petthecord/main.py
+++ b/src/petthecord/main.py
@@ -24,6 +24,12 @@ def main() -> None:
         help="Bind IP"
     )
     parser.add_argument(
+        "-o", "--origin",
+        default="https://ptc.pwn3t.ru",
+        metavar="PATH",
+        help="Root of the bot"
+    )
+    parser.add_argument(
         "-d", "--cache-dir",
         default="/var/cache/petthecord",
         metavar="PATH",
@@ -54,6 +60,7 @@ def main() -> None:
     bot = Bot(
         args.host,
         args.port,
+        args.origin,
         not args.no_cache,
         args.cache_dir,
         args.cache_lifetime,