Add --exclude flag (to avoid uploading thumbnails)
This commit is contained in:
parent
d8dc3e4ea8
commit
3970c611a4
@ -50,6 +50,8 @@ subdirectories will also be scanned.
|
|||||||
|
|
||||||
Other parameters are:
|
Other parameters are:
|
||||||
|
|
||||||
|
`--exclude <string>` - exclude any files that contain this string (commonly used to avoid uploading thumbnails).
|
||||||
|
|
||||||
`--watch xx` - specify how many seconds to wait between scanning the directory. The default is 10 seconds.
|
`--watch xx` - specify how many seconds to wait between scanning the directory. The default is 10 seconds.
|
||||||
|
|
||||||
`--username <username>` - an arbitrary string to show as the bot's username in the channel.
|
`--username <username>` - an arbitrary string to show as the bot's username in the channel.
|
||||||
|
12
dau.go
12
dau.go
@ -25,7 +25,7 @@ import (
|
|||||||
"golang.org/x/image/font/inconsolata"
|
"golang.org/x/image/font/inconsolata"
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentVersion = "0.5"
|
const currentVersion = "0.6"
|
||||||
|
|
||||||
var lastCheck = time.Now()
|
var lastCheck = time.Now()
|
||||||
var newLastCheck = time.Now()
|
var newLastCheck = time.Now()
|
||||||
@ -37,6 +37,7 @@ type Config struct {
|
|||||||
watch int
|
watch int
|
||||||
username string
|
username string
|
||||||
noWatermark bool
|
noWatermark bool
|
||||||
|
exclude string
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -102,6 +103,7 @@ func checkUpdates() {
|
|||||||
fmt.Println("----------- Release Info -----------")
|
fmt.Println("----------- Release Info -----------")
|
||||||
fmt.Println(latest.Body)
|
fmt.Println(latest.Body)
|
||||||
fmt.Println("------------------------------------")
|
fmt.Println("------------------------------------")
|
||||||
|
fmt.Println("Upgrade at https://github.com/tardisx/discord-auto-upload/releases/latest")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -114,6 +116,7 @@ func parseOptions() Config {
|
|||||||
pathFlag := getopt.StringLong("directory", 'd', "", "directory to scan, optional, defaults to current directory")
|
pathFlag := getopt.StringLong("directory", 'd', "", "directory to scan, optional, defaults to current directory")
|
||||||
watchFlag := getopt.Int16Long("watch", 's', 10, "time between scans")
|
watchFlag := getopt.Int16Long("watch", 's', 10, "time between scans")
|
||||||
usernameFlag := getopt.StringLong("username", 'u', "", "username for the bot upload")
|
usernameFlag := getopt.StringLong("username", 'u', "", "username for the bot upload")
|
||||||
|
excludeFlag := getopt.StringLong("exclude", 'x', "", "exclude files containing this string")
|
||||||
noWatermarkFlag := getopt.BoolLong("no-watermark", 'n', "do not put a watermark on images before uploading")
|
noWatermarkFlag := getopt.BoolLong("no-watermark", 'n', "do not put a watermark on images before uploading")
|
||||||
helpFlag := getopt.BoolLong("help", 'h', "help")
|
helpFlag := getopt.BoolLong("help", 'h', "help")
|
||||||
versionFlag := getopt.BoolLong("version", 'v', "show version")
|
versionFlag := getopt.BoolLong("version", 'v', "show version")
|
||||||
@ -146,6 +149,7 @@ func parseOptions() Config {
|
|||||||
newConfig.watch = int(*watchFlag)
|
newConfig.watch = int(*watchFlag)
|
||||||
newConfig.username = *usernameFlag
|
newConfig.username = *usernameFlag
|
||||||
newConfig.noWatermark = *noWatermarkFlag
|
newConfig.noWatermark = *noWatermarkFlag
|
||||||
|
newConfig.exclude = *excludeFlag
|
||||||
|
|
||||||
return newConfig
|
return newConfig
|
||||||
}
|
}
|
||||||
@ -168,10 +172,16 @@ func checkFile(path string, f os.FileInfo, err error, config Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fileEligible(config Config, file string) bool {
|
func fileEligible(config Config, file string) bool {
|
||||||
|
|
||||||
|
if config.exclude != "" && strings.Contains(file, config.exclude) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
extension := strings.ToLower(filepath.Ext(file))
|
extension := strings.ToLower(filepath.Ext(file))
|
||||||
if extension == ".png" || extension == ".jpg" || extension == ".gif" {
|
if extension == ".png" || extension == ".jpg" || extension == ".gif" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user