mirror of
https://github.com/alterware/aw-bot.git
synced 2025-10-26 14:15:54 +00:00
maint: remove migration code
This commit is contained in:
@@ -1,38 +1,10 @@
|
||||
import json
|
||||
import os
|
||||
from database import get_patterns, add_pattern
|
||||
from database import get_patterns
|
||||
|
||||
PATTERNS_FILE = "patterns.json"
|
||||
|
||||
BOT_DATA_DIR = os.getenv("BOT_DATA_DIR", "/bot-data")
|
||||
MIGRATION_FLAG = os.path.join(BOT_DATA_DIR, "migration_done.flag")
|
||||
|
||||
|
||||
def migrate_patterns():
|
||||
"""Migrate patterns.json to the database if not already done."""
|
||||
if os.path.exists(MIGRATION_FLAG):
|
||||
print("Not performing migration: already done")
|
||||
return
|
||||
|
||||
if not os.path.exists(PATTERNS_FILE):
|
||||
return
|
||||
|
||||
try:
|
||||
with open(PATTERNS_FILE, "r") as f:
|
||||
patterns = json.load(f)
|
||||
except (json.JSONDecodeError, FileNotFoundError):
|
||||
patterns = []
|
||||
|
||||
for pattern in patterns:
|
||||
add_pattern(pattern["regex"], pattern["response"])
|
||||
|
||||
with open(MIGRATION_FLAG, "w") as f:
|
||||
f.write("done")
|
||||
|
||||
print("Migration completed: patterns.json -> Database")
|
||||
|
||||
|
||||
migrate_patterns()
|
||||
|
||||
message_patterns = get_patterns()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user