mirror of
https://github.com/alterware/aw-bot.git
synced 2025-12-11 12:07:50 +00:00
feat: aka message slash command feature
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user