drivel/requests.go
2020-10-19 08:05:57 +02:00

61 lines
1.3 KiB
Go

package main
import (
"net/url"
"strings"
)
func LookupParameters(ids []string) string {
return "&id=" + strings.Join(ids, ",")
}
func UpdateStatusRequest(status string, mediaIDs []ObjectID, previousStatusID ObjectID) url.Values {
r := map[string][]string{
"status": {status},
"tweet_mode": {"extended"},
}
if len(mediaIDs) > 0 {
ids := []string{}
for _, id := range mediaIDs {
ids = append(ids, string(id))
}
r["media_ids"] = []string{strings.Join(ids, ",")}
}
if len(previousStatusID) > 0 {
r["in_reply_to_status_id"] = []string{string(previousStatusID)}
r["auto_populate_reply_metadata"] = []string{"true"}
}
return r
}
func UserTimelineParameters(flags userTimelineFlags, screenName string) string {
s := "&screen_name=" + screenName
if flags.withReplies {
return s
} else {
return s + "&exclude_replies=true"
}
}
func RetweetParameters(id string) string {
return id + ".json?tweet_mode=extended"
}
func LikeRequest(id string) url.Values {
return map[string][]string{
"id": {id},
"tweet_mode": {"extended"},
}
}
func UnlikeRequest(id string) url.Values {
return map[string][]string{
"id": {id},
"tweet_mode": {"extended"},
}
}
func DestroyParameters(id string) string {
return id + ".json?tweet_mode=extended"
}