See #4
This commit is contained in:
parent
7876ce8632
commit
9383cce16d
22
blurp.go
22
blurp.go
@ -22,10 +22,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
user string // account username
|
user string // account username
|
||||||
weeks int // number of weeks of statuses to retain
|
weeks int // number of weeks of statuses to retain
|
||||||
rate int // requests per second
|
rate int // requests per second
|
||||||
dry bool // whether or not to run in dry mode
|
dry bool // whether or not to run in dry mode
|
||||||
|
skipFavourites bool // whether or not to skip deleting favourites
|
||||||
|
skipPinned bool // whether or not to skip deleting pinned statuses
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -38,6 +40,8 @@ func init() {
|
|||||||
deleteCmd.Flags().IntVarP(&weeks, "weeks", "w", 2, "keep statuses NEWER than no. of weeks")
|
deleteCmd.Flags().IntVarP(&weeks, "weeks", "w", 2, "keep statuses NEWER than no. of weeks")
|
||||||
deleteCmd.Flags().IntVarP(&rate, "rate", "r", 1, "send a request every 'r' seconds")
|
deleteCmd.Flags().IntVarP(&rate, "rate", "r", 1, "send a request every 'r' seconds")
|
||||||
deleteCmd.Flags().BoolVarP(&dry, "dry", "d", false, "dry run mode (NO DELETION)")
|
deleteCmd.Flags().BoolVarP(&dry, "dry", "d", false, "dry run mode (NO DELETION)")
|
||||||
|
deleteCmd.Flags().BoolVarP(&skipFavourites, "skip-favourites", "f", false, "skip deletion of favourites")
|
||||||
|
deleteCmd.Flags().BoolVarP(&skipPinned, "skip-pinnned", "p", false, "skip deletion of pinned statuses")
|
||||||
rootCmd.AddCommand(deleteCmd)
|
rootCmd.AddCommand(deleteCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,6 +181,11 @@ var deleteCmd = &cobra.Command{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if status.Favourited && skipFavourites {
|
||||||
|
slog.Info(fmt.Sprintf("skipping %s (skip favourites: %v)", status.ID, skipFavourites))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
numHours := time.Duration(168 * weeks)
|
numHours := time.Duration(168 * weeks)
|
||||||
if t.Before(time.Now().Add(-time.Hour * numHours)) {
|
if t.Before(time.Now().Add(-time.Hour * numHours)) {
|
||||||
if !dry {
|
if !dry {
|
||||||
@ -275,6 +284,11 @@ func readAllPaged(authClient *auth.Client, accID string) ([]*models.Status, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
params := &accounts.AccountStatusesParams{ID: accID, MaxID: maxID}
|
params := &accounts.AccountStatusesParams{ID: accID, MaxID: maxID}
|
||||||
|
if skipPinned {
|
||||||
|
includePins := false
|
||||||
|
params.Pinned = &includePins
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := authClient.Client.Accounts.AccountStatuses(params, authClient.Auth)
|
resp, err := authClient.Client.Accounts.AccountStatuses(params, authClient.Auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("error fetching page", "error", err)
|
slog.Error("error fetching page", "error", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user