From 4ad3d24507a7bf66c1b16d419ccedd0b155787cc Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 28 Oct 2018 18:30:08 +0100 Subject: [PATCH] Move sqlite databases to a subfolder --- antiabuse.py | 8 +++++--- seen.py | 2 +- tell.py | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/antiabuse.py b/antiabuse.py index e226c93..51d5a3f 100755 --- a/antiabuse.py +++ b/antiabuse.py @@ -6,6 +6,8 @@ Licensed under GNU General Public License v2.0 """ import time, sqlite3 +DBPATH = "data/antiabuse.sqlite" + antiabuse = {} antiabuse["ignorelist"] = [] antiabuse["cooldown_l"] = {} @@ -13,7 +15,7 @@ antiabuse["cooldown"] = 3 # seconds def api_ignore(mask): antiabuse["ignorelist"].append(mask) - db = sqlite3.connect("antiabuse.sqlite") + db = sqlite3.connect(DBPATH) c = db.cursor() c.execute("INSERT INTO ignore (nick) VALUES (?)", (mask,)) c.close() @@ -24,7 +26,7 @@ def api_unignore(mask): if not mask in antiabuse["ignorelist"]: return False antiabuse['ignorelist'].remove(mask) - db = sqlite3.connect("antiabuse.sqlite") + db = sqlite3.connect(DBPATH) c = db.cursor() c.execute("DELETE FROM ignore WHERE nick = ?", (mask,)) c.close() @@ -137,7 +139,7 @@ def listignore(phenny, input): listignore.commands = ['listignore'] listignore.priority = 'high' -db = sqlite3.connect("antiabuse.sqlite") +db = sqlite3.connect(DBPATH) c = db.cursor() c.execute('''CREATE TABLE IF NOT EXISTS ignore (nick text)''') c.execute("SELECT * FROM ignore") diff --git a/seen.py b/seen.py index 6a14c5c..f7a9e18 100755 --- a/seen.py +++ b/seen.py @@ -10,7 +10,7 @@ import time from threading import Thread, Lock import sqlite3 -DBPATH = "seen.sqlite" +DBPATH = "data/seen.sqlite" updates = list() updates_l = Lock() diff --git a/tell.py b/tell.py index 6717c95..e3c4f39 100755 --- a/tell.py +++ b/tell.py @@ -10,12 +10,14 @@ import time import calendar import hashlib +DBPATH = "data/tell.sqlite" + tell_list = [] tell_pending = [] def tell_diskwr(): global tell_pending, tell_list - db = sqlite3.connect("tell.sqlite") + db = sqlite3.connect(DBPATH) c = db.cursor() for tr in tell_pending: if tr[0] == "del": @@ -126,7 +128,7 @@ note_join.event = 'JOIN' note_join.priority = 'low' note_join.nohook = True -db = sqlite3.connect("tell.sqlite") +db = sqlite3.connect(DBPATH) c = db.cursor() c.execute("CREATE TABLE IF NOT EXISTS tell (id INTEGER PRIMARY KEY, nick TEXT, tellee TEXT, msg TEXT, time INTEGER)") c.execute("SELECT * FROM tell")