From cf4fd799b47c6c1543d86bdaef5e14c5a47d4fc4 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 31 Jul 2023 00:10:15 -0700 Subject: [PATCH] Add `op` column to database Signed-off-by: Alek Ratzloff --- chanbans/db.py | 3 ++- chanbans/pull.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chanbans/db.py b/chanbans/db.py index d34e8f5..803191a 100644 --- a/chanbans/db.py +++ b/chanbans/db.py @@ -33,7 +33,8 @@ def get_db(db_path: str = DB_PATH): filename text, tim varchar(30), thumb_path text, - reason varchar(200) + reason varchar(200), + op boolean default 0 ); """ ) diff --git a/chanbans/pull.py b/chanbans/pull.py index 511b5e5..0175d3e 100644 --- a/chanbans/pull.py +++ b/chanbans/pull.py @@ -76,6 +76,7 @@ async def pull(): if key != "time" } post = defaultdict(lambda: None, posts[cols["post"]["data-pid"]]) + post["op"] = "(OP)" in str(cols["post"]) if "thumb" in post: thumb = post['thumb'] @@ -170,7 +171,7 @@ async def pull(): db.execute( """ - insert into bans (action, board, length, now, name, trip, com, time, sub, nsfw, thumb, ext, w, h, tn_w, tn_h, md5, fsize, filename, tim, thumb_path, reason) + insert into bans (action, board, length, now, name, trip, com, time, sub, nsfw, thumb, ext, w, h, tn_w, tn_h, md5, fsize, filename, tim, thumb_path, reason, op) values ( :action, :board, @@ -193,7 +194,8 @@ async def pull(): :filename, :tim, :thumb_path, - :reason + :reason, + :op ) """, post,