new retweet subcommand
This commit is contained in:
parent
d3632b9b4a
commit
b3b14e615e
16
Readme.md
16
Readme.md
|
@ -2,7 +2,7 @@ drivel
|
||||||
========
|
========
|
||||||
|
|
||||||
drivel is a Twitter command line interface for status updates, media upload,
|
drivel is a Twitter command line interface for status updates, media upload,
|
||||||
your home timeline, your mention timeline, replies, quotes and likes.
|
your home timeline, your mention timeline, replies, quotes, retweets and likes.
|
||||||
My personal opinion is that you shouldn't be on Twitter in the first place, but
|
My personal opinion is that you shouldn't be on Twitter in the first place, but
|
||||||
anyway...
|
anyway...
|
||||||
|
|
||||||
|
@ -40,21 +40,27 @@ To like a tweet with a specific ID:
|
||||||
drivel like TWEET_ID
|
drivel like TWEET_ID
|
||||||
```
|
```
|
||||||
|
|
||||||
To update your status with optional media upload...
|
To retweet a tweet with a specific ID:
|
||||||
|
|
||||||
|
```
|
||||||
|
drivel retweet TWEET_ID
|
||||||
|
```
|
||||||
|
|
||||||
|
To update your status with optional media upload:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
drivel status STATUS [FILE1, FILE2, ...]
|
drivel status STATUS [FILE1, FILE2, ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
...reply to a tweet with a specific ID...
|
To reply to a tweet with a specific ID:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
drivel reply TWEET_ID MESSAGE [FILE1, FILE2, ...]
|
drivel reply TWEET_ID MESSAGE [FILE1, FILE2, ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
...or quote a tweet with a specific ID...
|
To quote a tweet with a specific ID:
|
||||||
|
|
||||||
```
|
```
|
||||||
drivel quote TWEET_ID MESSAGE [FILE1, FILE2, ...]
|
drivel quote TWEET_ID MESSAGE [FILE1, FILE2, ...]
|
||||||
|
@ -112,4 +118,4 @@ with id 1013200061533171712
|
||||||
final note
|
final note
|
||||||
----------
|
----------
|
||||||
|
|
||||||
You can buy me a beer [here](http://paypal.me/AlexanderWeinhold).
|
You can buy me a beer [here](http://paypal.me/AlexanderWeinhold).
|
||||||
|
|
27
drivel.go
27
drivel.go
|
@ -25,6 +25,7 @@ const (
|
||||||
MENTIONS_ENDPOINT = "https://api.twitter.com/1.1/statuses/mentions_timeline.json?tweet_mode=extended&count=200"
|
MENTIONS_ENDPOINT = "https://api.twitter.com/1.1/statuses/mentions_timeline.json?tweet_mode=extended&count=200"
|
||||||
HOME_ENDPOINT = "https://api.twitter.com/1.1/statuses/home_timeline.json?tweet_mode=extended&count=200"
|
HOME_ENDPOINT = "https://api.twitter.com/1.1/statuses/home_timeline.json?tweet_mode=extended&count=200"
|
||||||
LOOKUP_ENDPOINT = "https://api.twitter.com/1.1/statuses/lookup.json?tweet_mode=extended"
|
LOOKUP_ENDPOINT = "https://api.twitter.com/1.1/statuses/lookup.json?tweet_mode=extended"
|
||||||
|
RETWEET_ENDPOINT = "https://api.twitter.com/1.1/statuses/retweet/"
|
||||||
LIKE_ENDPOINT = "https://api.twitter.com/1.1/favorites/create.json"
|
LIKE_ENDPOINT = "https://api.twitter.com/1.1/favorites/create.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -479,7 +480,6 @@ func updateStatus(args []string, previous ObjectID, embedTweet ObjectID) {
|
||||||
d.status[0] += " " + tweets[0].URL()
|
d.status[0] += " " + tweets[0].URL()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.push(httpClient, previous)
|
d.push(httpClient, previous)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,6 +557,30 @@ func home(args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RetweetParameters(id string) string {
|
||||||
|
return id + ".json"
|
||||||
|
}
|
||||||
|
|
||||||
|
func retweet(args []string) error {
|
||||||
|
log := func(err error) { optLogFatal("retweet", err) }
|
||||||
|
if len(args) != 1 {
|
||||||
|
fmt.Fprintln(os.Stderr, "USAGE: drivel retweet TWEET_ID")
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
client := getClient()
|
||||||
|
id := args[0]
|
||||||
|
tweets := lookup(client, []string{id})
|
||||||
|
if len(tweets) != 1 {
|
||||||
|
log(errors.New("Could not find tweet " + id))
|
||||||
|
}
|
||||||
|
body := send(client, RETWEET_ENDPOINT+RetweetParameters(id), nil)
|
||||||
|
var retweet Status
|
||||||
|
err := json.Unmarshal(body, &retweet)
|
||||||
|
log(err)
|
||||||
|
fmt.Println("Retweeted", tweets[0])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func LikeRequest(id string) url.Values {
|
func LikeRequest(id string) url.Values {
|
||||||
return map[string][]string{
|
return map[string][]string{
|
||||||
"id": {id},
|
"id": {id},
|
||||||
|
@ -586,6 +610,7 @@ func main() {
|
||||||
goutil.NewCommand("mentions", mentions, "get your mention timeline"),
|
goutil.NewCommand("mentions", mentions, "get your mention timeline"),
|
||||||
goutil.NewCommand("reply", reply, "reply to a tweet with a specific ID"),
|
goutil.NewCommand("reply", reply, "reply to a tweet with a specific ID"),
|
||||||
goutil.NewCommand("quote", quote, "quote retweet a tweet with a specific ID"),
|
goutil.NewCommand("quote", quote, "quote retweet a tweet with a specific ID"),
|
||||||
|
goutil.NewCommand("retweet", retweet, "retweet a tweet with a specific ID"),
|
||||||
goutil.NewCommand("like", like, "like a tweet with a specific ID"),
|
goutil.NewCommand("like", like, "like a tweet with a specific ID"),
|
||||||
}
|
}
|
||||||
err := goutil.Execute(commands)
|
err := goutil.Execute(commands)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user