I've been doing this all wrong for a long time
This commit is contained in:
parent
27b62feb5f
commit
b6558ccdd5
7 changed files with 43 additions and 31 deletions
|
@ -7,17 +7,17 @@ db_ready = False
|
|||
|
||||
def db_init(db):
|
||||
"""check to see that our db has the horoscope table and return a connection."""
|
||||
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def horoscope(inp, db=None, notice=None, nick=None):
|
||||
"""horoscope <sign> -- Get your horoscope."""
|
||||
|
||||
if not db_ready:
|
||||
db_init(db)
|
||||
db_init(db)
|
||||
|
||||
# check if the user asked us not to save his details
|
||||
dontsave = inp.endswith(" dontsave")
|
||||
|
|
Reference in a new issue