diff --git a/files/classes/orgy.py b/files/classes/orgy.py new file mode 100644 index 000000000..83fa8d0b5 --- /dev/null +++ b/files/classes/orgy.py @@ -0,0 +1,49 @@ +import time +from math import floor +from random import randint +from urllib.parse import parse_qs, urlencode, urlparse +from flask import g + +from sqlalchemy import Column, ForeignKey +from sqlalchemy.dialects.postgresql import TSVECTOR +from sqlalchemy.orm import relationship, scoped_session +from sqlalchemy.schema import FetchedValue +from sqlalchemy.sql.sqltypes import * + +from files.classes import Base +from files.helpers.config.const import * +from files.helpers.lazy import lazy +from files.helpers.regex import * +from files.helpers.sorting_and_time import * + +class Orgy(Base): + __tablename__ = "orgies" + + youtube_id = Column(String, primary_key=True) + title = Column(String) + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + + def __repr__(self): + return f"<{self.__class__.__name__}(id={self.youtube_id}, title={self.title})>" + + +def get_orgy(): + orgy = g.db.query(Orgy).one_or_none() + return orgy + +def create_orgy(youtube_id, title): + assert not get_orgy() + assert re.match(yt_id_regex, youtube_id) + orgy = Orgy(title=title, youtube_id=youtube_id) + g.db.add(orgy) + g.db.flush() + g.db.commit() + +def end_orgy(): + assert get_orgy() + g.db.query(Orgy).delete() + g.db.flush() + g.db.commit() \ No newline at end of file diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index ae0b85349..7448f9c4c 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -519,6 +519,7 @@ PERMS = { # Minimum admin_level to perform action. 'LOTTERY_VIEW_PARTICIPANTS': 2, 'POST_COMMENT_INFINITE_PINGS': 2, 'IGNORE_1WEEk_EDITING_LIMIT': 2, + 'ORGIES': 2, 'ADMIN_REMOVE': 3, 'ADMIN_ACTIONS_REVERT': 3, diff --git a/files/routes/admin.py b/files/routes/admin.py index 7fb0b11ce..a3537a2b5 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -9,6 +9,7 @@ from psycopg2.errors import UniqueViolation from files.__main__ import app, cache, limiter from files.classes import * +from files.classes.orgy import * from files.helpers.actions import * from files.helpers.alerts import * from files.helpers.cloudflare import * @@ -1906,3 +1907,27 @@ def admin_reset_password(user_id, v): send_repeatable_notification(user.id, text) return {"message": f"@{user.username}'s password has been reset! The new password has been messaged to them!"} + +@app.get("/admin/orgy") +@admin_level_required(PERMS['ORGIES']) +def orgy_control(v): + return render_template("admin/orgy_control.html", v=v, orgy=get_orgy()) + +@app.post("/admin/start_orgy") +@admin_level_required(PERMS['ORGIES']) +def start_orgy(v): + youtube_id = request.values.get("youtube_id") + title = request.values.get("title") + + assert youtube_id + assert title + + create_orgy(youtube_id, title) + + return redirect("/chat") + +@app.post("/admin/stop_orgy") +@admin_level_required(PERMS['ORGIES']) +def stop_orgy(v): + end_orgy() + return redirect("/chat") \ No newline at end of file diff --git a/files/routes/chat.py b/files/routes/chat.py index ab9b2aa80..5ecb6719e 100644 --- a/files/routes/chat.py +++ b/files/routes/chat.py @@ -13,6 +13,7 @@ from files.helpers.media import * from files.helpers.sanitize import * from files.helpers.alerts import push_notif from files.routes.wrappers import * +from files.classes.orgy import * from files.__main__ import app, cache, limiter @@ -35,7 +36,20 @@ messages = cache.get(f'messages') or {} def chat(v): if not v.admin_level and TRUESCORE_CHAT_MINIMUM and v.truescore < TRUESCORE_CHAT_MINIMUM: abort(403, f"Need at least {TRUESCORE_CHAT_MINIMUM} truescore for access to chat!") - return render_template("orgy.html", v=v, messages=messages) + orgy = get_orgy() + if orgy: + return render_template("orgy.html", v=v, messages=messages, orgy = orgy) + else: + return render_template("chat.html", v=v, messages=messages) + +@app.get("/old_chat") +@limiter.limit(DEFAULT_RATELIMIT) +@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) +@is_not_permabanned +def old_chat(v): + if not v.admin_level and TRUESCORE_CHAT_MINIMUM and v.truescore < TRUESCORE_CHAT_MINIMUM: + abort(403, f"Need at least {TRUESCORE_CHAT_MINIMUM} truescore for access to chat!") + return render_template("chat.html", v=v, messages=messages) @socketio.on('speak') @is_not_permabanned diff --git a/files/templates/admin/orgy_control.html b/files/templates/admin/orgy_control.html new file mode 100644 index 000000000..305e0d18d --- /dev/null +++ b/files/templates/admin/orgy_control.html @@ -0,0 +1,52 @@ +{% extends "default.html" %} + +{% block pagetitle %}Edit {{SITE_NAME}}'s rules{% endblock %} + +{% block content %} +{% if msg %}{{macros.alert(msg, false)}}{% endif %} +
+
+
+
+

Orgy Control Panel

+
+
+
+
+ {%if not orgy%} +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+ {%else%} +
+ +
+ +
+
+ {%endif%} +
+
+
+
+
+{% endblock %} diff --git a/files/templates/orgy.html b/files/templates/orgy.html index e27bd8326..f71a3d302 100644 --- a/files/templates/orgy.html +++ b/files/templates/orgy.html @@ -12,9 +12,9 @@
-

Deboonking Aliens with Style 'n' Grace

+

{{orgy.title}}

- +
{{macros.chat_users_list()}}
diff --git a/files/templates/rules_rDrama.html b/files/templates/rules_rDrama.html index 7df594c41..264f37aef 100644 --- a/files/templates/rules_rDrama.html +++ b/files/templates/rules_rDrama.html @@ -1,6 +1,6 @@

CURRENT EVENTS:

-

Bing Bing Wahoo Pet Contest

Dramacoin prizes!
-

Independence Gay Grill-Off

BADGE
+

Bing Bing Wahoo Pet Contest

Dramacoin prizes!
+

Independence Gay Grill-Off

BADGE



@@ -10,7 +10,7 @@
-

𝐜𝐚𝐫𝐩 𝐰𝐨𝐳 𝐞𝐫𝐞

\ No newline at end of file +

𝐜𝐚𝐫𝐩 𝐰𝐨𝐳 𝐞𝐫𝐞

+

gaming!

\ No newline at end of file diff --git a/migrations/20230702-orgies.sql b/migrations/20230702-orgies.sql new file mode 100644 index 000000000..219c2a4cd --- /dev/null +++ b/migrations/20230702-orgies.sql @@ -0,0 +1,4 @@ +CREATE TABLE public.orgies ( + youtube_id character varying(12) NOT NULL, + title character varying(1000) NOT NULL +); \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 09b1591ab..d28d80e78 100644 --- a/nginx.conf +++ b/nginx.conf @@ -24,6 +24,10 @@ server { proxy_pass http://localhost:5001/chat; include includes/headers; } + location /old_chat { + proxy_pass http://localhost:5001/old_chat; + include includes/headers; + } location =/offline.html { alias /rDrama/files/assets/offline.html; include includes/headers; diff --git a/schema.sql b/schema.sql index fbff00c4b..63fe20b36 100644 --- a/schema.sql +++ b/schema.sql @@ -1126,6 +1126,13 @@ CREATE TABLE public.votes ( coins smallint DEFAULT 1 NOT NULL ); +-- +-- Name: orgies, Type: TABLE; Schema: public; Owner: - +-- +CREATE TABLE public.orgies ( + youtube_id character varying(12) NOT NULL, + title character varying(1000) NOT NULL +); -- -- Name: award_relationships id; Type: DEFAULT; Schema: public; Owner: -