Move database/persistence initialization into a function

This allows us to postpone init_db(). One advantage of this is that
specifying AWAY in botconfig.py won't overwrite the away list from the
DB anymore, but properly get added to (as would be expected).
This commit is contained in:
Janik Kleinhoff 2014-12-08 13:18:34 +00:00
parent 7ad48ee412
commit 1d06b68d24
2 changed files with 47 additions and 44 deletions

View File

@ -87,6 +87,8 @@ var.DISCONNECTED = {} # players who got disconnected
var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME)
var.init_db()
var.OPPED = False # Keeps track of whether the bot is opped
if botconfig.DEBUG_MODE:

View File

@ -658,9 +658,10 @@ class AleatoireMode(object):
import sqlite3
conn = sqlite3.connect("data.sqlite3", check_same_thread = False)
c = conn.cursor()
with conn:
c = conn.cursor()
def init_db():
with conn:
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)') # whoops, i mean cloak, not nick
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role