feat: Replace SQLite with per-user JSON storage (fixes #2)
- Add storage.py with load_user(), save_user(), next_bounty_id() - Rewrite commands.py to use JSON storage (simplified) - Remove db.py, schema.sql, cron.py, test_db.py - Update SPEC.md to reflect new architecture - Admin model removed (anyone can add, creator only can edit/delete) - No reminders in v1
This commit is contained in:
@@ -12,7 +12,6 @@ from telegram.ext import (
|
||||
filters,
|
||||
)
|
||||
|
||||
import db
|
||||
import commands
|
||||
|
||||
logging.basicConfig(
|
||||
@@ -21,14 +20,12 @@ logging.basicConfig(
|
||||
)
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Token from environment or config
|
||||
BOT_TOKEN = os.environ.get("JIGAIDO_BOT_TOKEN", "")
|
||||
|
||||
|
||||
def build_app() -> Application:
|
||||
app = Application.builder().token(BOT_TOKEN).build()
|
||||
|
||||
# Core commands
|
||||
app.add_handler(CommandHandler("start", commands.cmd_start))
|
||||
app.add_handler(CommandHandler("help", commands.cmd_help))
|
||||
app.add_handler(CommandHandler("bounty", commands.cmd_bounty))
|
||||
@@ -41,22 +38,22 @@ def build_app() -> Application:
|
||||
app.add_handler(CommandHandler("admin_add", commands.cmd_admin_add))
|
||||
app.add_handler(CommandHandler("admin_remove", commands.cmd_admin_remove))
|
||||
|
||||
# Fallback: unknown commands
|
||||
app.add_handler(MessageHandler(filters.COMMAND, commands.cmd_help))
|
||||
|
||||
return app
|
||||
|
||||
|
||||
async def post_init(app: Application) -> None:
|
||||
# Set bot commands in menu
|
||||
await app.bot.set_my_commands([
|
||||
("bounty", "List bounties"),
|
||||
("my", "Your tracked bounties"),
|
||||
("add", "Add a bounty"),
|
||||
("track", "Track a bounty"),
|
||||
("untrack", "Stop tracking"),
|
||||
("help", "Show help"),
|
||||
])
|
||||
await app.bot.set_my_commands(
|
||||
[
|
||||
("bounty", "List bounties"),
|
||||
("my", "Your tracked bounties"),
|
||||
("add", "Add a bounty"),
|
||||
("track", "Track a bounty"),
|
||||
("untrack", "Stop tracking"),
|
||||
("help", "Show help"),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -64,9 +61,6 @@ def main() -> None:
|
||||
log.error("JIGAIDO_BOT_TOKEN environment variable not set.")
|
||||
sys.exit(1)
|
||||
|
||||
db.init_db()
|
||||
log.info("Database initialized.")
|
||||
|
||||
app = build_app()
|
||||
app.post_init = post_init
|
||||
|
||||
|
||||
Reference in New Issue
Block a user