Skip to content

Add /schedule command for managing scheduled jobs via Telegram #150

Description

@felixeu31

Problem

The scheduler backend (APScheduler + SQLite + EventBus) is fully functional, but there's no built-in user-facing interface to manage scheduled jobs. The current workaround is having Claude interact with the SQLite database directly via sqlite3 commands (possible since the bot runs on a VPS with CLI access), but this still requires a bot restart after every change and is a workaround rather than a proper solution.

Expected behavior

Users should be able to create, list, and manage scheduled jobs directly from the Telegram chat using a /schedule command.

Current architecture

The JobScheduler class already supports add_job(), remove_job(), and get_jobs(). It persists jobs to the scheduled_jobs SQLite table and loads them on startup. However, the instance is created locally in run_application() and is not injected into bot dependencies, making it inaccessible from command handlers.

Proposed solution

  1. Inject JobScheduler into bot dependencies alongside ClaudeIntegration, SessionManager, etc.
  2. Add a ScheduleCommandHandler registered for /schedule with subcommands:
    • /schedule list — show all active jobs
    • /schedule add <name> <cron> <prompt> — create a new job (auto-fills chat_id, working_directory, created_by from context)
    • /schedule remove <job_id> — soft-delete a job
    • /schedule pause <job_id> / /schedule resume <job_id> — toggle is_active
  3. Hot-reload: call JobScheduler.add_job() directly so new jobs are live immediately without bot restart

Auto-populated fields

When creating via /schedule add:

  • job_id → auto-generated from name + random suffix
  • target_chat_ids → current chat ID
  • working_directory → user's active project directory
  • created_by → user's Telegram ID

Key files

  • run_application() — expose JobScheduler in bot deps
  • New ScheduleCommandHandler — command handler for /schedule
  • JobScheduler — minor API adjustments if needed

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions