Skip to content

Commit eb3f28f

Browse files
committed
feat: add default date regex pattern for monitor regex strategy
1 parent 4a47770 commit eb3f28f

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

internal/modules/gobot/commands3.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ func handleMonitorUpdatesManage(s *discordgo.Session, i *discordgo.InteractionCr
343343
respond(s, i, "❌ URL is required for add action", false)
344344
return
345345
}
346+
if strategy == "regex" && pattern == "" {
347+
pattern = `([A-Z][a-z]{2,9} [0-9]{1,2}, [0-9]{4}|[0-9]{4}-[0-9]{2}-[0-9]{2})`
348+
}
346349
cmd = []string{autoarScript, "monitor", "updates", "add", "-u", *url, "--strategy", strategy}
347350
if pattern != "" {
348351
cmd = append(cmd, "--pattern", pattern)

internal/modules/gobot/commands_registration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func registerAllCommands(s *discordgo.Session) {
393393
{Type: discordgo.ApplicationCommandOptionInteger, Name: "id", Description: "Target ID (for remove/start/stop)", Required: false},
394394
{Type: discordgo.ApplicationCommandOptionString, Name: "url", Description: "URL (for add/start/stop by URL)", Required: false},
395395
{Type: discordgo.ApplicationCommandOptionString, Name: "strategy", Description: "Strategy: hash|size|headers|regex (for add, default: hash)", Required: false},
396-
{Type: discordgo.ApplicationCommandOptionString, Name: "pattern", Description: "Regex pattern if strategy=regex (for add)", Required: false},
396+
{Type: discordgo.ApplicationCommandOptionString, Name: "pattern", Description: "Regex pattern if strategy=regex (default: date format)", Required: false},
397397
{Type: discordgo.ApplicationCommandOptionInteger, Name: "interval", Description: "Interval in seconds (for start, default: 86400)", Required: false},
398398
{Type: discordgo.ApplicationCommandOptionBoolean, Name: "all", Description: "Apply to all targets (for start/stop)", Required: false},
399399
},

internal/modules/monitor/monitor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ func Run(opts Options) error {
4141
if opts.Strategy == "" {
4242
opts.Strategy = "hash"
4343
}
44+
if opts.Strategy == "regex" && opts.Pattern == "" {
45+
opts.Pattern = `([A-Z][a-z]{2,9} [0-9]{1,2}, [0-9]{4}|[0-9]{4}-[0-9]{2}-[0-9]{2})`
46+
}
4447
return handleAdd(opts.URL, opts.Strategy, opts.Pattern)
4548
case "remove":
4649
if opts.ID > 0 {

0 commit comments

Comments
 (0)