fix has_table, move age and minutes to trainset

pull/193/head
bobloy 4 years ago
parent e0a361b952
commit 47269ba8f4

@ -402,7 +402,13 @@ class Chatter(Cog):
) )
@commands.is_owner() @commands.is_owner()
@chatter.command(name="minutes") @chatter.group(name="trainset")
async def chatter_trainset(self, ctx: commands.Context):
"""Commands for configuring training"""
pass
@commands.is_owner()
@chatter_trainset.command(name="minutes")
async def minutes(self, ctx: commands.Context, minutes: int): async def minutes(self, ctx: commands.Context, minutes: int):
""" """
Sets the number of minutes the bot will consider a break in a conversation during training Sets the number of minutes the bot will consider a break in a conversation during training
@ -418,7 +424,7 @@ class Chatter(Cog):
await ctx.tick() await ctx.tick()
@commands.is_owner() @commands.is_owner()
@chatter.command(name="age") @chatter_trainset.command(name="age")
async def age(self, ctx: commands.Context, days: int): async def age(self, ctx: commands.Context, days: int):
""" """
Sets the number of days to look back Sets the number of days to look back

@ -5,7 +5,7 @@ class MyDumbSQLStorageAdapter(SQLStorageAdapter):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(SQLStorageAdapter, self).__init__(**kwargs) super(SQLStorageAdapter, self).__init__(**kwargs)
from sqlalchemy import create_engine from sqlalchemy import create_engine, inspect
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
self.database_uri = kwargs.get("database_uri", False) self.database_uri = kwargs.get("database_uri", False)
@ -31,7 +31,7 @@ class MyDumbSQLStorageAdapter(SQLStorageAdapter):
dbapi_connection.execute("PRAGMA journal_mode=WAL") dbapi_connection.execute("PRAGMA journal_mode=WAL")
dbapi_connection.execute("PRAGMA synchronous=NORMAL") dbapi_connection.execute("PRAGMA synchronous=NORMAL")
if not self.engine.dialect.has_table(self.engine, "Statement"): if not inspect(self.engine).has_table('Statement'):
self.create_database() self.create_database()
self.Session = sessionmaker(bind=self.engine, expire_on_commit=True) self.Session = sessionmaker(bind=self.engine, expire_on_commit=True)

Loading…
Cancel
Save