diff --git a/Readme.md b/Readme.md index 8cc94e9..3b9d1d2 100644 --- a/Readme.md +++ b/Readme.md @@ -19,22 +19,22 @@ go build drivel.go credentials.go usage ----- -To get the last 200 tweets of your home timeline: +To get up to the last 200 tweets of your home timeline: ``` drivel home ``` -To get the last 200 tweets of your mention timeline: +To get up to the last 200 tweets of your mention timeline: ``` drivel mentions ``` -To get the last 200 tweets of @USER: +To get up to the last 200 tweets of @USER: ``` -drivel timeline USER +drivel timeline [--with-replies] USER ``` To like a tweet with a specific ID: @@ -58,7 +58,7 @@ drivel lookup TWEET_ID1 [TWEET_ID2 TWEET_ID3 ...] To wipe your timeline and likes (keepDays defaults to 10, can only reach back as far as the result of the timeline): ``` -drivel wipe [--keepDays=N] +drivel wipe [--keep-days=N] ``` @@ -86,47 +86,7 @@ with any number of files, as long as they are .jpg, .png, .gif or .mp4 and small drivel will automatically split large status messages and multiple files into separate tweets belonging to the same thread. -example: - -``` -$ ./drivel status "First Message" -Did not find /home/alexander/.drivel, creating. -Go to https://apps.twitter.com/app/new to register a new app -and create an access token - -Consumer Key: someconsumerkey -Consumer Secret: somesecret -Access Token: sometoken -Access Token Secret: sometokensecret -==> Updated status to 'First Message' with id 1013198854823514112 -$ -$ ./drivel status "Maxitest Lorem ipsum dolor sit amet, consetetur sadipscing elitr, -sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, -sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet -clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod -tempor invidunt ut labor" *.jpg *.mp4 *.gif -==> Uploaded 7-Sins-in-the-Digital-World.jpg with id 1013200017602043904 -==> Uploaded DifferenceTechEnthusiasts.jpg with id 1013200023608287234 -==> Uploaded disappointednotsurprised.jpg with id 1013200028339507200 -==> Uploaded fpalm30c3.jpg with id 1013200033053896704 -==> Updated status to 'Maxitest Lorem ipsum dolor sit amet, consetetur sadipscing -elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam -erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. -Stet clita kasd gubergren, no sea takimata sanctus est' with id 1013200053387874305 -==> Uploaded howtoeven.jpg with id 1013200057108135936 -==> Updated status to 'Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, -consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labor' -with id 1013200061533171712 -==> Uploaded disgusted-clint-eastwood.gif with id 1013200063978500097 -==> Updated status to '' with id 1013200074254450688 -==> Uploaded headwall.gif with id 1013200076871696384 -==> Updated status to '' with id 1013200088049602562 -==> Uploaded KittingUp.mp4 with id 1013200090595545089 -==> Updated status to '' with id 1013200101811122178 -==> Uploaded SteveHughes_Metal.mp4 with id 1013200104357064704 -==> Updated status to '' with id 1013200119813033985 -``` +The results of the 'home' and 'mentions' commands can be filtered to exclude certain user names. Create text files 'FilterHome' and 'FilterMentions' in HOME/.drivel and list excluded users line by line. final note diff --git a/drivel.go b/drivel.go index d9b0d79..3b0314f 100644 --- a/drivel.go +++ b/drivel.go @@ -647,16 +647,33 @@ func home(args []string) error { return nil } -func UserTimelineParameters(screenName string) string { - return "&screen_name=" + screenName +func UserTimelineParameters(flags userTimelineFlags, screenName string) string { + s := "&screen_name=" + screenName + if flags.withReplies { + return s + } else { + return s + "&exclude_replies=true" + } } -func userTimeline(args []string) error { - tweets := timeline(TIMELINE_ENDPOINT + UserTimelineParameters(args[0])) +func userTimeline(flags userTimelineFlags, args []string) error { + tweets := timeline(TIMELINE_ENDPOINT + UserTimelineParameters(flags, args[0])) PrintTweets(tweets, nil) return nil } +type userTimelineFlags struct { + withReplies bool +} + +func userTimelineCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { + f := userTimelineFlags{} + flagsInit := func(s *flag.FlagSet) { + s.BoolVar(&f.withReplies, "with-replies", false, "include replies in timeline") + } + return flagsInit, func(args []string) error { return userTimeline(f, args) } +} + func RetweetParameters(id string) string { return id + ".json" } @@ -789,7 +806,7 @@ type wipeFlags struct { func wipeCommand() (goutil.CommandFlagsInit, goutil.CommandFunc) { f := wipeFlags{} flagsInit := func(s *flag.FlagSet) { - s.IntVar(&f.keepDays, "keepDays", WIPE_KEEP_DAYS, "don't wipe the last N days") + s.IntVar(&f.keepDays, "keep-days", WIPE_KEEP_DAYS, "don't wipe the last N days") } return flagsInit, func([]string) error { return wipe(f) } } @@ -844,7 +861,7 @@ func main() { goutil.NewCommand("status", status, "post a status with message and/or media"), goutil.NewCommand("home", home, "get your home timeline"), goutil.NewCommand("mentions", mentions, "get your mention timeline"), - goutil.NewCommand("timeline", userTimeline, "get timeline of a specific user"), + goutil.NewCommandWithFlags("timeline", userTimelineCommand, "get timeline of a specific user"), goutil.NewCommand("lookup", lookup, "lookup tweets with specific IDs"), goutil.NewCommand("reply", reply, "reply to a tweet with a specific ID"), goutil.NewCommand("quote", quote, "quote retweet a tweet with a specific ID"),