mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-26 09:41:31 +08:00
feat: implement album handling rules and refactor related logic
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
RuleStorNameChosen = "CHOSEN"
|
||||
RuleStorNameChosen = "CHOSEN"
|
||||
RuleDirPathNewForAlbum = "NEW-FOR-ALBUM" // create a new directory for album files
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ type RuleType string
|
||||
const (
|
||||
FileNameRegex RuleType = "FILENAME-REGEX"
|
||||
MessageRegex RuleType = "MESSAGE-REGEX"
|
||||
IsAlbum RuleType = "IS-ALBUM"
|
||||
)
|
||||
|
||||
func (r RuleType) String() string {
|
||||
@@ -12,5 +13,5 @@ func (r RuleType) String() string {
|
||||
}
|
||||
|
||||
func Values() []RuleType {
|
||||
return []RuleType{FileNameRegex, MessageRegex}
|
||||
return []RuleType{FileNameRegex, MessageRegex, IsAlbum}
|
||||
}
|
||||
|
||||
38
pkg/rule/is_album.go
Normal file
38
pkg/rule/is_album.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package rule
|
||||
|
||||
import (
|
||||
ruleenum "github.com/krau/SaveAny-Bot/pkg/enums/rule"
|
||||
)
|
||||
|
||||
var _ RuleClass[bool] = (*RuleMediaType)(nil)
|
||||
|
||||
type RuleMediaType struct {
|
||||
storInfo
|
||||
matchAlbum bool
|
||||
}
|
||||
|
||||
func (r RuleMediaType) Type() ruleenum.RuleType {
|
||||
return ruleenum.IsAlbum
|
||||
}
|
||||
|
||||
func (r RuleMediaType) Match(input bool) (bool, error) {
|
||||
return r.matchAlbum == input, nil
|
||||
}
|
||||
|
||||
func (r RuleMediaType) StorageName() string {
|
||||
return r.storName
|
||||
}
|
||||
|
||||
func (r RuleMediaType) StoragePath() string {
|
||||
return r.storPath
|
||||
}
|
||||
|
||||
func NewRuleMediaType(storName, storPath string, matchAlbum bool) (*RuleMediaType, error) {
|
||||
return &RuleMediaType{
|
||||
storInfo: storInfo{
|
||||
storName: storName,
|
||||
storPath: storPath,
|
||||
},
|
||||
matchAlbum: matchAlbum,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user