← Back to Skills
Web Search

srt

khj809 By khj809 👁 12 views ▲ 0 votes

Korean SRT (Super Rapid Train) search, reservation, and booking management.

GitHub
---
name: srt
description: Korean SRT (Super Rapid Train) search, reservation, and booking management
homepage: https://github.com/khj809/openclaw-srt-skill
user-invocable: true
metadata:
  {
    "openclaw":
      {
        "emoji": "πŸš…",
        "requires": { "bins": ["python3", "uv"] },
        "install": [
          {"id": "uv", "kind": "uv", "package": "SRTrain", "label": "Install SRTrain (uv)"}
        ]
      },
  }
---

# SRT Korean Train Service Skill

OpenClaw skill for managing Korean SRT (Super Rapid Train) reservations with search, booking, view, and cancellation capabilities.

## Features

- πŸ” **Search trains** between stations with real-time seat availability
- 🎫 **Make reservations** with automatic rate limiting to protect your account
- πŸ“‹ **View bookings** to see all active reservations
- πŸ—‘οΈ **Cancel bookings** with confirmation prompts
- πŸ€– **AI-friendly** JSON output for programmatic access
- πŸ›‘οΈ **Rate limiting** to prevent account blocking (3s between reservations, 5s between searches)
- ⚠️ **Retry protection** with maximum 10 attempts per session

## Prerequisites

1. **Python 3.10+** installed
2. **SRT account** with phone number and password
3. **OpenClaw** installed and configured

## Configuration

Set your SRT credentials as environment variables:

```bash
export SRT_PHONE="010-1234-5678"
export SRT_PASSWORD="your_password"
```

Add these to your shell profile (`~/.zshrc`, `~/.bashrc`, etc.) for persistence.

**Security Note:** Avoid committing credentials to version control.

**Important:** Phone number must include hyphens in the format `010-XXXX-XXXX`

## Usage

### User-Invocable Command

Use the `/srt` slash command in OpenClaw:

```
/srt search --departure "μˆ˜μ„œ" --arrival "λΆ€μ‚°" --date "20260217" --time "140000"
/srt reserve --train-id "1"
/srt reserve --retry --timeout-minutes 60
/srt reserve --retry --train-id "1,3,5" --timeout-minutes 60
/srt log -n 30
/srt list
/srt cancel --reservation-id "RES123456"
```

### Natural Language (AI-Orchestrated)

The AI can invoke this skill based on user intent:

**Examples:**
- "2μ›” 17일에 μˆ˜μ„œμ—μ„œ λΆ€μ‚° κ°€λŠ” κΈ°μ°¨ κ²€μƒ‰ν•΄μ€˜" *(Search trains)*
- "제일 λΉ λ₯Έκ±Έλ‘œ μ˜ˆμ•½ν•΄μ€˜" *(Reserve first available)*
- "λ‚΄ μ˜ˆμ•½ ν™•μΈν•΄μ€˜" *(List bookings)*
- "λΆ€μ‚° μ˜ˆμ•½ μ·¨μ†Œν•΄μ€˜" *(Cancel booking)*

### Direct CLI Usage

```bash
# Search trains
uv run --with SRTrain python3 scripts/srt_cli.py search \
  --departure "μˆ˜μ„œ" \
  --arrival "λΆ€μ‚°" \
  --date "20260217" \
  --time "140000" \
  --passengers "adult=2"

# Make reservation (single attempt)
uv run --with SRTrain python3 scripts/srt_cli.py reserve --train-id "1"

# Make reservation with automatic retry - all trains (background mode recommended)
uv run --with SRTrain python3 scripts/srt_cli.py reserve --retry \
  --timeout-minutes 60 \
  --wait-seconds 10

# Make reservation with automatic retry - specific trains only
uv run --with SRTrain python3 scripts/srt_cli.py reserve --retry \
  --train-id "1,3,5" \
  --timeout-minutes 60 \
  --wait-seconds 10

# Check reservation log
uv run --with SRTrain python3 scripts/srt_cli.py log -n 30

# View bookings
uv run --with SRTrain python3 scripts/srt_cli.py list --format json

# Cancel booking
uv run --with SRTrain python3 scripts/srt_cli.py cancel \
  --reservation-id "RES123456" \
  --confirm
```

## Common Korean Station Names

**Main SRT Stations:**
- μˆ˜μ„œ (Suseo) - Seoul SRT station
- λΆ€μ‚° (Busan)
- λ™λŒ€κ΅¬ (Dongdaegu) - Daegu
- λŒ€μ „ (Daejeon)
- μ²œμ•ˆμ•„μ‚° (Cheonan-Asan)
- μ˜€μ†‘ (Osong)
- 광주솑정 (Gwangju-Songjeong)
- μšΈμ‚° (Ulsan)
- 포항 (Pohang)
- κ²½μ£Ό (Gyeongju)
- κΉ€μ²œκ΅¬λ―Έ (Gimcheon-Gumi)
- 읡산 (Iksan)
- μ „μ£Ό (Jeonju)
- λͺ©ν¬ (Mokpo)
- μ‹ κ²½μ£Ό (Singyeongju)

**Important:** Station names MUST be in Korean (Hangul) for the SRT API to work correctly.

## Date and Time Formats

- **Date:** YYYYMMDD (e.g., `20260217` for February 17, 2026)
- **Time:** HHMMSS (e.g., `140000` for 2:00 PM, `093000` for 9:30 AM)

## Tools for AI Agent

This skill provides 5 tools for managing SRT train reservations:

### 1. search_trains
Search for available trains between stations.

**Usage:**
```bash
uv run --with SRTrain python3 scripts/srt_cli.py search \
  --departure "μˆ˜μ„œ" \
  --arrival "λΆ€μ‚°" \
  --date "20260217" \
  --time "120000"
```

**Returns:** JSON array of available trains with seat availability

**JSON Format:**
```json
{
  "success": true,
  "data": [
    {
      "train_id": "1",
      "train_number": "301",
      "train_name": "SRT301",
      "departure_time": "120500",
      "arrival_time": "143000",
      "departure_station": "μˆ˜μ„œ",
      "arrival_station": "λΆ€μ‚°",
      "seat_available": true,
      "general_seat": "μ˜ˆμ•½κ°€λŠ₯",
      "special_seat": "μ˜ˆμ•½κ°€λŠ₯"
    }
  ]
}
```

### 2. make_reservation
Reserve trains with optional automatic retry support.

**Usage (single attempt):**
```bash
uv run --with SRTrain python3 scripts/srt_cli.py reserve --train-id "1"
```

**Usage (with retry):**
```bash
# Try all trains
uv run --with SRTrain python3 scripts/srt_cli.py reserve --retry \
  --timeout-minutes 60 \
  --wait-seconds 10

# Try specific trains only
uv run --with SRTrain python3 scripts/srt_cli.py reserve --retry \
  --train-id "1,3,5" \
  --timeout-minutes 60 \
  --wait-seconds 10
```

**Options:**
- `--train-id`: Specific train(s) to reserve (comma-separated, e.g., "1" or "1,3,5"; omit to try all trains)
- `--retry`: Enable automatic retry on failure
- `--timeout-minutes`: Maximum retry duration in minutes (default: 60)
- `--wait-seconds`: Wait time between retry attempts in seconds (default: 10)

**Behavior with --retry:**
1. Cycles through all available trains from search results
2. Waits `--wait-seconds` between attempts (plus rate-limiting delays)
3. Continues until success or timeout
4. Logs progress to `~/.openclaw/tmp/srt/reserve.log`

**Returns:** Reservation details with payment deadline

**JSON Format:**
```json
{
  "success": true,
  "data": {
    "reservation_id": "RES123456",
    "journey_date": "20260217",
    "journey_time": "120500",
    "departure": "μˆ˜μ„œ",
    "arrival": "λΆ€μ‚°",
    "train_number": "301",
    "seat_number": "3A",
    "payment_required": true,
    "attempts": 12
  }
}
```

**Note:** 
- Payment must be completed manually by user via SRT app/website
- For retry mode, run in background with exec tool and periodically check logs

### 3. view_bookings
List all current reservations.

**Usage:**
```bash
uv run --with SRTrain python3 scripts/srt_cli.py list --format json
```

**Returns:** JSON array of active reservations

**JSON Format:**
```json
{
  "success": true,
  "data": [
    {
      "reservation_id": "RES123456",
      "journey_date": "20260217",
      "journey_time": "120500",
      "departure": "μˆ˜μ„œ",
      "arrival": "λΆ€μ‚°",
      "train_number": "301",
      "seat_number": "3A",
      "payment_required": true
    }
  ]
}
```

### 4. cancel_booking
Cancel a reservation by ID.

**Usage:**
```bash
uv run --with SRTrain python3 scripts/srt_cli.py cancel \
  --reservation-id "RES123456" \
  --confirm
```

**Returns:** Cancellation confirmation

**JSON Format:**
```json
{
  "success": true,
  "data": {
    "success": true,
    "reservation_id": "RES123456",
    "message": "Reservation cancelled successfully"
  }
}
```

### 5. check_log
Check the progress of reservation attempts (especially useful for retry mode).

**Usage:**
```bash
uv run --with SRTrain python3 scripts/srt_cli.py log -n 30
```

**Returns:** Last N lines of reservation log file (`~/.openclaw/tmp/srt/reserve.log`)

**Options:**
- `-n, --lines`: Number of lines to show (default: 20)

**Log Format Example:**
```
[2026-02-03 11:00:00] INFO: === SRT μ˜ˆμ•½ μ‹œμž‘ (μž¬μ‹œλ„ λͺ¨λ“œ) ===
[2026-02-03 11:00:00] INFO: νƒ€μž„μ•„μ›ƒ: 60λΆ„
[2026-02-03 11:00:00] INFO: μž¬μ‹œλ„ 간격: 10초
[2026-02-03 11:00:00] INFO: λŒ€μƒ μ—΄μ°¨: 1,3,5 (총 3개)
[2026-02-03 11:00:05] INFO: === μ‹œλ„ #1 (μ—΄μ°¨ 1/3) ===
[2026-02-03 11:00:05] INFO: 🎫 μ˜ˆμ•½ μ‹œλ„ 쀑... (μ—΄μ°¨ 301, 120500)
[2026-02-03 11:00:06] WARN: ❌ μ’Œμ„ μ—†μŒ (μ—΄μ°¨ 301)
[2026-02-03 11:00:06] INFO: ⏳ 10초 λŒ€κΈ° ν›„ μž¬μ‹œλ„...
[2026-02-03 11:00:26] INFO: === μ‹œλ„ #2 (μ—΄μ°¨ 2/3) ===
...
[2026-02-03 11:05:00] SUCCESS: βœ… μ˜ˆμ•½ 성곡!
```

## Error Handling

The skill provides clear, actionable error messages:

**Common Errors:**

1. **AuthenticationFailed**
   - Invalid credentials
   - **Solution:** Check phone number and password in config

2. **NoSeatsAvailable**
   - Train is sold out
   - **Solution:** Try next train or different time
   - **Exit code:** 1 (retryable)

3. **StationNotFound**
   - Invalid station name
   - **Solution:** Use Korean station names from the list above

4. **NoTrainsFound**
   - No trains for specified route/time
   - **Solution:** Try different date or time

5. **RateLimitExceeded**
   - Too many retry attempts (max 10 per session)
   - **Solution:** Wait a few minutes before trying again

6. **NetworkError**
   - Connection timeout or failure
   - **Solution:** Check internet connection and retry

**Exit Codes:**
- `0` - Success
- `1` - Retryable error (e.g., no seats available)
- `2` - Fatal error (e.g., authentication failed, invalid input)

## ⚠️ Rate Limiting and Account Protection

To protect your SRT account from being blocked by the server:

- **Automatic delays** between requests:
  - Minimum 3 seconds between reservation attempts
  - Minimum 5 seconds between search requests
- **Maximum 10 retry attempts** per session
- **Exponential backoff** after failures (3s β†’ 5s β†’ 10s β†’ 15s β†’ 20s β†’ 30s)

**What this means for users:**
- The skill will automatically wait between requests
- You'll see waiting messages like "⏳ SRT μ„œλ²„ 보호λ₯Ό μœ„ν•΄ λŒ€κΈ° 쀑 (3초)"
- If you hit the retry limit, wait a few minutes before trying again

**For AI orchestration:**
- The AI should inform users about delays during retries
- Example: "μž¬μ‹œλ„ μ€‘μž…λ‹ˆλ‹€. μ„œλ²„ 보호λ₯Ό μœ„ν•΄ 3초 λŒ€κΈ°ν•©λ‹ˆλ‹€..."
- After 10 failed attempts, suggest alternatives like different times or dates

## Natural Language Handling

When users make requests in Korean, the AI should:

1. **Extract parameters** from natural language:
   - Stations (must convert to Korean if given in English)
   - Date (relative dates like "내일", "λ‹€μŒμ£Ό κΈˆμš”μΌ" β†’ YYYYMMDD)
   - Time (relative times like "

... (truncated)
web search

Comments

Sign in to leave a comment

Loading comments...