|
@@ -18,7 +18,14 @@ def get_game_id(game: str, c=None) -> int:
|
|
|
if c is None:
|
|
|
c = DB.cursor()
|
|
|
c.execute('SELECT id FROM games WHERE name = ?', [game])
|
|
|
- return c.fetchone()[0]
|
|
|
+ res = c.fetchone()
|
|
|
+ if res is not None:
|
|
|
+ return res[0]
|
|
|
+ else:
|
|
|
+ c.execute('INSERT INTO games (name) VALUES (?)', [game])
|
|
|
+ DB.commit()
|
|
|
+ c.execute('SELECT id FROM games WHERE name = ?', [game])
|
|
|
+ return c.fetchone()[0]
|
|
|
|
|
|
def add_msg(user: str, content: str, game: str, c=None):
|
|
|
if c is None:
|