summary refs log tree commit diff
diff options
context:
space:
mode:
authormeltland <[email protected]>2025-03-27 21:44:44 -0400
committermeltland <[email protected]>2025-03-27 21:44:44 -0400
commit981467625ebcce35305b24db0b1c094eea16fa73 (patch)
treebf09d70edd89268d191e20ee78aa51973bfafe57
parent4013bf977f8c48a32bfbb363e0bdccf1817cefa6 (diff)
stuff and things and the likes
-rw-r--r--config.json9
-rw-r--r--main.py18
2 files changed, 24 insertions, 3 deletions
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..ec0b2ac
--- /dev/null
+++ b/config.json
@@ -0,0 +1,9 @@
+{
+    "#note": {
+        "#": "Set the below values to what you need them to be!",
+        "whitelisted_urls": "URLs that are whitelisted for attachments.",
+        "gitlab_contributors_url": "URL to GitLab contributors API endpoint for your repo, or null to disable it."
+    },
+    "whitelisted_urls": ["u.cubeupload.com", "files.catbox.moe", "litter.catbox.moe", "i.ibb.co", "cubeupload.com", "media.tenor.com", "tenor.com", "c.tenor.com", "meower.fraudulent.loan", "soktdeer.com", "boss.soktdeer.com"],
+    "gitlab_contributors_url": "https://gitlab.com/api/v4/projects/67813797/repository/contributors?order_by=name"
+}
\ No newline at end of file
diff --git a/main.py b/main.py
index 8aad57f..48cdb1c 100644
--- a/main.py
+++ b/main.py
@@ -9,11 +9,22 @@ from passlib.hash import scrypt
 import db

 import uuid

 import secrets

+import requests

 import time

 from urllib.parse import urlparse

 

+with open("config.json", "r") as f:

+    config_file = json.load(f)

+

 version = "Helium-1.0.0a"

-attachment_whitelist = ["u.cubeupload.com", "files.catbox.moe", "litter.catbox.moe", "i.ibb.co", "cubeupload.com", "media.tenor.com", "tenor.com", "c.tenor.com", "meower.fraudulent.loan", "fraudulent.loan", "deer.fraudulent.loan"]

+attachment_whitelist = config_file["whitelisted_urls"]

+

+contributors = []

+if config_file["gitlab_contributors_url"]:

+    r = requests.get(config_file["gitlab_contributors_url"])

+    if r.status_code == 200:

+        for i in r.json():

+            contributors.append(i["name"])

 

 addr = "localhost"

 port = 3636

@@ -85,7 +96,8 @@ class util:
             "version": version,

             "ulist": ulist,

             "messages": db.posts.get_recent(),

-            "locked": locked

+            "locked": locked,

+            "server_contributors": contributors

         })

     

     def ulist():

@@ -162,7 +174,7 @@ async def handler(websocket):
             if not ratelimits[str(websocket.id)] <= time.time():

                 await websocket.send(util.error("ratelimited", None))

                 continue

-            ratelimits[str(websocket.id)] = time.time() + 0.15

+            ratelimits[str(websocket.id)] = time.time() + 0.025

             try:

                 r = json.loads(message)

             except: