From 42c9bb87fd19f49e902b44bd00fdc8b4d33f51e2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 22 Feb 2022 14:39:02 +0200 Subject: [PATCH] df --- Dockerfile | 2 +- files/classes/exiles.py | 1 + files/routes/comments.py | 7 ++++--- files/routes/subs.py | 4 ++-- requirements.txt | 1 - ubuntu_setup | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20c190ea0..3f846d3de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 -RUN apt update && apt -y upgrade && apt install -y python3.8 python3-pip supervisor libenchant1c2a +RUN apt update && apt -y upgrade && apt install -y supervisor python3-pip ffmpeg COPY supervisord.conf /etc/supervisord.conf diff --git a/files/classes/exiles.py b/files/classes/exiles.py index b2469e55a..d34b45999 100644 --- a/files/classes/exiles.py +++ b/files/classes/exiles.py @@ -7,6 +7,7 @@ class Exile(Base): __tablename__ = "exiles" user_id = Column(Integer, ForeignKey("users.id"), primary_key=True) sub = Column(String, ForeignKey("subs.name"), primary_key=True) + exiler_id = Column(Integer, ForeignKey("users.id")) def __repr__(self): return f"" \ No newline at end of file diff --git a/files/routes/comments.py b/files/routes/comments.py index 2896cdf2e..016c03ba6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -17,9 +17,10 @@ import requests from shutil import copyfile from json import loads from collections import Counter -from enchant import Dict +from nltk.corpus import words -d = Dict("en_US") +words = set(WORDLE_LIST) | set(words.words()) +words = set([x for x in words if len(x) == 5]) IMGUR_KEY = environ.get("IMGUR_KEY").strip() @@ -1101,7 +1102,7 @@ def handle_wordle_action(cid, v): try: guess = request.values.get("guess").strip().lower() except: abort(400) - if len(guess) != 5 or not d.check(guess) and guess not in WORDLE_LIST: + if len(guess) != 5 or guess not in words: return {"error": "Not a valid guess!"}, 400 if status == "active": diff --git a/files/routes/subs.py b/files/routes/subs.py index 4bd3d9ad6..b69fcd8ab 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -26,7 +26,7 @@ def exile_post(v, pid): u = p.author if u.admin_level < 2 and not u.exiled_from(sub): - exile = Exile(user_id=u.id, sub=sub) + exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{p.title}]({p.sl})") @@ -79,7 +79,7 @@ def exile_comment(v, cid): u = c.author if u.admin_level < 2 and not u.exiled_from(sub): - exile = Exile(user_id=u.id, sub=sub) + exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{c.permalink}]({c.sl})") diff --git a/requirements.txt b/requirements.txt index 17a01ccb4..c757811c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,6 @@ requests SQLAlchemy psycopg2-binary pusher_push_notifications -pyenchant youtube-dl yattag webptools \ No newline at end of file diff --git a/ubuntu_setup b/ubuntu_setup index 31d8e61a9..521673c50 100644 --- a/ubuntu_setup +++ b/ubuntu_setup @@ -1,7 +1,7 @@ cd /Drama sudo apt update sudo apt -y upgrade -sudo apt -y install postgresql postgresql-contrib redis-server python3-pip gunicorn ffmpeg libenchant1c2a +sudo apt -y install postgresql postgresql-contrib redis-server python3-pip ffmpeg cp pg_hba.conf /etc/postgresql/12/main/pg_hba.conf sudo service postgresql restart sudo psql -U postgres -f schema.sql postgres