feat(/add): time parsing, link uniqueness, admin-only #60

Closed
shoko wants to merge 2 commits from fix/issue-45-add-command-update into main
Owner

Summary

Updates /add command per issue #45:

  1. Time Parsing: Parse time in HH:MM format after date

    • Example: /add Fix bug https://github.com/foo/bar april 15 14:30
    • If last arg matches HH:MM and previous arg is a parsed date, treats as time
  2. Link Uniqueness: check_link_unique now returns conflicting bounty ID

    • Duplicate links rejected with error message including existing bounty ID
    • Example: ⛔ A bounty with this link already exists: #3
  3. Admin-Only: cmd_add now catches PermissionError

    • Non-admin users see: ⛔ Only admins can add bounties.

Changes

  • core/services.py:

    • check_link_unique() returns int | None (bounty ID or None)
    • add_bounty() includes bounty ID in duplicate error
    • update_bounty() updated to use new return type
  • apps/telegram-bot/commands.py:

    • Added _is_time_format() and _set_time_on_timestamp() helpers
    • Updated parse_args() to parse HH:MM time after date
    • cmd_add catches PermissionError and ValueError
    • Updated usage and help text

Testing

# Time parsing
/add Fix bug https://github.com/foo/bar april 15 14:30

# Admin-only (non-admin user gets)
⛔ Only admins can add bounties.

# Duplicate link
⛔ A bounty with this link already exists: #3

Fixes #45

## Summary Updates `/add` command per issue #45: 1. **Time Parsing**: Parse time in `HH:MM` format after date - Example: `/add Fix bug https://github.com/foo/bar april 15 14:30` - If last arg matches `HH:MM` and previous arg is a parsed date, treats as time 2. **Link Uniqueness**: `check_link_unique` now returns conflicting bounty ID - Duplicate links rejected with error message including existing bounty ID - Example: `⛔ A bounty with this link already exists: #3` 3. **Admin-Only**: `cmd_add` now catches `PermissionError` - Non-admin users see: `⛔ Only admins can add bounties.` ## Changes - `core/services.py`: - `check_link_unique()` returns `int | None` (bounty ID or None) - `add_bounty()` includes bounty ID in duplicate error - `update_bounty()` updated to use new return type - `apps/telegram-bot/commands.py`: - Added `_is_time_format()` and `_set_time_on_timestamp()` helpers - Updated `parse_args()` to parse HH:MM time after date - `cmd_add` catches PermissionError and ValueError - Updated usage and help text ## Testing ```bash # Time parsing /add Fix bug https://github.com/foo/bar april 15 14:30 # Admin-only (non-admin user gets) ⛔ Only admins can add bounties. # Duplicate link ⛔ A bounty with this link already exists: #3 ``` Fixes #45
shoko added 1 commit 2026-04-04 07:44:42 +02:00
- Add time parsing (HH:MM format) after date
  Example: /add Fix bug https://github.com/foo/bar april 15 14:30
- Update check_link_unique to return conflicting bounty ID
- Add_bounty now includes bounty ID in duplicate link error
- cmd_add now catches PermissionError and displays admin-only message
- Update usage text and help message
- Fixes #45
han approved these changes 2026-04-04 09:33:51 +02:00
han left a comment
Collaborator

lgtm

lgtm
shoko added 1 commit 2026-04-04 09:39:51 +02:00
shoko closed this pull request 2026-04-04 12:59:49 +02:00

Pull request closed

Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/jigaido#60