feat: show typing status during processing
This commit is contained in:
1 parent
6abea3acc8
commit
33cc2b8a15
4 files changed
+116
-52
No files matched your search
+4
-3
@@ -1,3 +1,4 @@
|
||||
from contextlib import closing
|
||||
import os
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
@@ -17,7 +18,7 @@ def connect(db_path: str | None = None) -> sqlite3.Connection:
|
||||
|
||||
|
||||
def init_db(db_path: str | None = None) -> None:
|
||||
with connect(db_path) as connection:
|
||||
with closing(connect(db_path)) as connection, connection:
|
||||
connection.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
@@ -31,7 +32,7 @@ def init_db(db_path: str | None = None) -> None:
|
||||
|
||||
|
||||
def get_tone_of_voice(user_id: int, db_path: str | None = None) -> str:
|
||||
with connect(db_path) as connection:
|
||||
with closing(connect(db_path)) as connection, connection:
|
||||
connection.execute(
|
||||
"INSERT OR IGNORE INTO users (telegram_user_id) VALUES (?)", (user_id,)
|
||||
)
|
||||
@@ -43,7 +44,7 @@ def get_tone_of_voice(user_id: int, db_path: str | None = None) -> str:
|
||||
|
||||
def save_tone_of_voice(user_id: int, tone_of_voice: str, db_path: str | None = None) -> None:
|
||||
tone = tone_of_voice.strip()[:1200]
|
||||
with connect(db_path) as connection:
|
||||
with closing(connect(db_path)) as connection, connection:
|
||||
connection.execute(
|
||||
"""
|
||||
INSERT INTO users (telegram_user_id, tone_of_voice, updated_at)
|
||||
|
||||
Reference in new issue
Block a user