Skip to content

mhajder/thelounge-plugin-scheduler

Repository files navigation

The Lounge Plugin: Scheduler

A comprehensive plugin for The Lounge that allows users to schedule messages to be sent at specific times to channels or users.

Features

  • Schedule Messages: Send messages at specific times (HH:MM or HH:MM:SS format) or using custom cron expressions
  • Timezone Support: Configure different timezones for schedules
  • Schedule Management: Add, edit, delete, enable/disable schedules
  • List & Info: View all schedules and detailed information
  • Persistent Storage: Schedules are saved and restored between restarts
  • Automatic Execution: Uses cron jobs for reliable scheduling
  • Per-User Schedules: Each user can only manage their own schedules
  • One-Time Schedules: Create schedules that run once and are automatically deleted
  • Ownership Protection: Users can only view, edit, or delete their own schedules
  • Seconds Support: Optionally specify seconds in time format (HH:MM:SS)
  • Custom Cron Expressions: Use full cron expressions for advanced scheduling patterns

Installation

git clone https://github.com/mhajder/thelounge-plugin-scheduler.git
thelounge install file:./thelounge-plugin-scheduler/

Usage

The plugin adds a /schedule command with the following subcommands:

Add a Schedule

/schedule add <time|--cron <expression>> <channel/user> <message> [options]

Parameters:

  • <time>: Time in HH:MM or HH:MM:SS format (24-hour), OR
  • --cron <expression>: Custom cron expression for advanced scheduling
  • <channel/user>: Target channel (with #) or username (without #) for private messages
  • <message>: The message to send (use quotes for multi-word messages)

Options:

  • --network <network>: Target network (default: current network)
  • --timezone <timezone>: Timezone for execution (default: auto-detected from client)
  • --once: Schedule will run only once and be automatically deleted after execution

Time Format Examples:

  • HH:MM - Standard time format (e.g., 14:00 for 2:00 PM daily)
  • HH:MM:SS - Time with seconds (e.g., 14:30:45 for 2:30:45 PM daily)

Cron Expression Format:

Standard cron format: * * * * * or with seconds: * * * * * *

  • Seconds (optional): 0-59
  • Minutes: 0-59
  • Hours: 0-23
  • Day of Month: 1-31
  • Month: 1-12
  • Day of Week: 0-7 (0 and 7 are Sunday)

Examples:

# Send message to a channel at 13:30 every day
/schedule add 13:30 #general "Hello everyone!"

# Send message with seconds precision
/schedule add 14:30:45 #general "Precise timing message"

# Send to specific channel with custom timezone
/schedule add 09:00 #general "Good morning!" --timezone America/New_York

# Send private message to a user
/schedule add 14:00 alice "Don't forget the meeting!"

# Send to different network
/schedule add 12:00 #dev "Lunch time!" --network freenode

# Create a one-time reminder
/schedule add 14:30 #main "Meeting in 30 minutes!" --once

# One-time private message reminder
/schedule add 08:00 bob "Wake up call!" --once

# Use cron expression for weekdays at 9 AM
/schedule add --cron "0 9 * * 1-5" #work "Weekday morning reminder"

# Use cron with seconds for every 30 seconds
/schedule add --cron "*/30 * * * * *" #test "Every 30 seconds"

# Use cron for first day of month at noon
/schedule add --cron "0 12 1 * *" #general "Monthly reminder"

# Cron with one-time execution
/schedule add --cron "0 15 * * 5" #general "This Friday at 3 PM" --once

List Schedules

/schedule list

Shows all your schedules with their status, type (one-time ⚡ or recurring 🔄), time, target, and last execution.

Note: You can only see schedules that you created. Each user's schedules are isolated.

Edit a Schedule

/schedule edit <id> <field> <value>

Available fields: time, cronExpression, message, target, network, timezone

Note: You can only edit schedules that you created. When editing between time and cronExpression, you can switch the schedule type.

Examples:

/schedule edit abc123 message "Updated message"
/schedule edit abc123 time 14:30
/schedule edit abc123 time 14:30:45
/schedule edit abc123 cronExpression "0 9 * * 1-5"
/schedule edit abc123 timezone Europe/London

Delete a Schedule

/schedule delete <id>
# or
/schedule remove <id>

Note: You can only delete schedules that you created.

Enable/Disable Schedules

/schedule enable <id>
/schedule disable <id>

Note: You can only enable/disable schedules that you created.

Get Schedule Information

/schedule info <id>

Shows detailed information about a specific schedule, including whether it's a one-time or recurring schedule.

Note: You can only view information for schedules that you created.

Help

/schedule
# or
/schedule help

Shows the help message with all available commands.

Configuration

The plugin stores schedules per user in separate files:

  • <thelounge-home>/packages/thelounge-plugin-scheduler/schedules-<username>.json

Each user's schedules are completely isolated from other users. Users can only manage their own schedules.

Development

Requirements

  • Node.js 18.0.0 or higher
  • pnpm package manager
  • The Lounge 4.0.0 or higher

Testing

The project uses Vitest for testing:

# Run all tests
pnpm test

# Run with coverage
pnpm test:coverage

# Run specific test file
pnpm test tests/utils.test.js

Code Quality

The project uses ESLint and Prettier for code quality:

# Check linting
pnpm lint

# Fix linting issues
pnpm lint:fix

# Check formatting
pnpm format:check

# Format code
pnpm format

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A comprehensive plugin for The Lounge that allows users to schedule messages to be sent at specific times to channels or users.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors