feat: aka message slash command feature

This commit is contained in:
2025-11-30 10:49:47 +01:00
parent 0b5308d1e9
commit 726e19565e
3 changed files with 85 additions and 2 deletions

View File

@@ -126,3 +126,33 @@ def is_user_blacklisted(user_id: int) -> bool:
conn.close()
return result is not None
def add_aka_response(aka: str, response: str) -> None:
"""
Insert a new AKA/response pair into the database.
"""
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute(
"INSERT INTO aka_list (aka, response) VALUES (?, ?)", (aka, response)
)
conn.commit()
conn.close()
def search_aka(keyword: str) -> str | None:
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# Exact match (case-insensitive)
cursor.execute(
"SELECT response FROM aka_list WHERE LOWER(aka) = LOWER(?) LIMIT 1", (keyword,)
)
row = cursor.fetchone()
conn.close()
return row[0] if row else None

View File

@@ -16,3 +16,9 @@ CREATE TABLE IF NOT EXISTS black_list (
date_assigned TEXT,
reason TEXT
);
CREATE TABLE IF NOT EXISTS aka_list (
id INTEGER PRIMARY KEY AUTOINCREMENT,
aka TEXT NOT NULL,
response TEXT NOT NULL
);