dfMerge branch 'frost' of https://github.com/Aevann1/Drama into frost

master
Aevann1 2022-02-22 13:02:24 +00:00
commit 12e310422e
7 changed files with 28 additions and 10 deletions

View File

@ -1,6 +1,16 @@
FROM ubuntu:20.04
RUN apt update && apt -y upgrade && apt install -y python3.8 python3-pip supervisor libenchant1c2a
RUN apt update
RUN apt -y upgrade
RUN apt install -y supervisor
RUN apt install -y python3-pip
RUN apt install -y python3-enchant
RUN apt install -y libenchant1c2a
COPY supervisord.conf /etc/supervisord.conf

View File

@ -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"<Exile(user_id={self.user_id}, sub={self.sub})>"

View File

@ -113,7 +113,7 @@ def handler(signum, frame):
def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
signal.signal(signal.SIGALRM, handler)
signal.alarm(1)
signal.alarm(2)
if sanitized.count(':') > 100: abort(418)
if sanitized.count('@') > 50: abort(418)
@ -305,7 +305,7 @@ def handler2(signum, frame):
def filter_emojis_only(title, edit=False, graceful=False):
signal.signal(signal.SIGALRM, handler2)
signal.alarm(1)
signal.alarm(2)
if title.count(':') > 100: abort(418)
if title.count('@') > 50: abort(418)
@ -342,6 +342,8 @@ def filter_emojis_only(title, edit=False, graceful=False):
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
title = re.sub(f'(?<!"):{old}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" delay="0" class="{classes}" src="/static/assets/images/emojis/{emoji}.webp">', title, re.I)
title = re.sub('~~(.*?)~~', r'<del>\1</del>', title)
signal.alarm(0)
if len(title) > 1500 and not graceful: abort(400)

View File

@ -17,9 +17,14 @@ import requests
from shutil import copyfile
from json import loads
from collections import Counter
from enchant import Dict
d = Dict("en_US")
import nltk
nltk.download('words')
from nltk.corpus import words
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 +1106,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":

View File

@ -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})")

View File

@ -11,6 +11,7 @@ gunicorn
lxml
mistletoe
matplotlib
nltk
Pillow
psutil
pyotp
@ -20,7 +21,6 @@ requests
SQLAlchemy
psycopg2-binary
pusher_push_notifications
pyenchant
youtube-dl
yattag
webptools

View File

@ -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